Hi guys
I have an abstract class that looks as follows.
public abstract class Entity<PK extends Serializable> implements Serializable {
private PK id;
//getters and setters generated here....
}
public class User extends Entity<Long> {
//all attributes, getters and setters are done here...
}
My Service looks like this
public interface EntityService {
public void create(Entity<? extends Serializable> entity) throws ServiceException;
public boolean delete(Entity<? extends Serializable> entity) throws ServiceException;
}
and my implementation is on class EntityServiceImpl
.
When I do a Web Service generation with Apache CXF, I get the following exception:
Error: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.reflect.TypeVariable
java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.reflect.TypeVariable
at org.apache.cxf.frontend.AbstractServiceFactory.createService(AbstractServiceFactory.java:41)
at org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor.process(JavaToWSDLProcessor.java:128)
at org.apache.cxf.tools.java2ws.JavaToWSContainer.processWSDL(JavaToWSContainer.java:109)
at org.apache.cxf.tools.java2ws.JavaToWSContainer.execute(JavaToWSContainer.java:75)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:58)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:40)
at org.apache.cxf.tools.java2ws.JavaToWS.run(JavaToWS.java:77)
at org.apache.cxf.tools.java2ws.JavaToWS.main(JavaToWS.java:45)
Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.reflect.TypeVariable
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:232)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:211)
My question:
How do I generate a Web Service that has Parametrized Types or uses Generics?