In my webproject using tomee, openejb and jackson (among a few other things like hibernate, most important dependencies are listed below) I've got a problem that I just can't fix.
Having a structure as follows:
public abstract class AbstractCrud<E extends AbstractEntity>{
[...]
public abstract ResultWrapper<E> create (E entity);
[...]
}
@Path("/path")
@Consumes("application/json")
@Produces("application/json")
public class ImplementingClass extends AbstractCrud<ImplementingEntity>{
@PUT
@Override
public ResultWrapper<ImplementingEntity> create(final ImplementingEntity entity){
//Some Code
}
}
I get this warning: Both package.ImplementingClass#create and package.ImplementingClass#create are equal candidates for handling the current request which can lead to unpredictable results
Followed by this exception:
Cannot construct instance of `package.AbstractEntity` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [...]
My best guess is that the annotation scanner doesn't filter for bridge methods and thus the method using the abstract class is used which (of course) can't be instantiated. I have searched on how to exclude methods from the scanner (or complete classes) but haven't found anything.
So my question is: can I exclude classes or methods from the scanner, if not, what else can I do to prevent this from happening?
Dependencies (Using Java 8):
All of those should be the newest versions.
The problem in this case is that the method is generic, the java compiler generates a synthetic method, so when cxf calls getMethod on your class, it will see two 'create' methods, and one is synthetic, but regardless, that resource method will be registered twice.
This is a bug in CXF. CXF-7670