Hi all,
I'd like to return some Hibernate 3 entities in the responses of WebServices exposed throught JAX-WS RI in Tomcat 5.5.
Because I need to do some property lazy fetching on this entities, I use Javassist instrumentation. Basically, it automatically adds new properties to my entities. Types of this new properties are not simple types or classes but they are interfaces.
The problems begin when I deploy the solution in Tomcat because: 1/ JAXB (used by JAX-WS RI) can't handle interfaces (to generate WSDL I suppose) and 2/ I don't want my WS client to see all this generated properties.
Do you have some ideas how to resolve this problem?
It may be a bad design to return the hibernate objects in the WebServices but, in my case, this WebServices are precisely a data layer (to search, load and persists objects).
Here is an extract of the exception I get when deploying the solution:
Code:
GRAVE: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: Unable to create JAXBContext due to the security restriction
javax.xml.ws.WebServiceException: Unable to create JAXBContext due to the security restriction
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:131)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:63)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:224)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:308)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:174)
[...]
at java.lang.Thread.run(Thread.java:595)
Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
org.hibernate.bytecode.javassist.FieldHandler is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at org.hibernate.bytecode.javassist.FieldHandler
at public org.hibernate.bytecode.javassist.FieldHandler com.connectivit.bpihub.dal.RoutingRule.getFieldHandler()
at com.connectivit.bpihub.dal.RoutingRule
at public com.connectivit.bpihub.dal.RoutingRule com.connectivit.bpihub.webservices.structures.MessageToProcess.getRoutingRule()
[...]
at com.connectivit.bpihub.webservices.jaxws.GetMessageListToProcessResponse
org.hibernate.bytecode.javassist.FieldHandler does not have a no-arg default constructor.
this problem is related to the following location:
at org.hibernate.bytecode.javassist.FieldHandler
at public org.hibernate.bytecode.javassist.FieldHandler com.connectivit.bpihub.dal.RoutingRule.getFieldHandler()
[...]
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:124)
... 24 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
org.hibernate.bytecode.javassist.FieldHandler is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at org.hibernate.bytecode.javassist.FieldHandler
at public org.hibernate.bytecode.javassist.FieldHandler com.connectivit.bpihub.dal.RoutingRule.getFieldHandler()
[...]
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:422)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:270)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:103)
at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:89)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:126)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:125)
... 26 more
Thanks for your help,
Florent