Tuesday, June 1, 2010

Error: Unable to create JAXBContext

Well, few weeks back I was experimenting if I could create a java web service having a method that excepts XMLDocument or XMLElement as argument or probably return the same. While trying to expose this java class as services I constantly hit error:


javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:158)

................
Caused By: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
oracle.xml.scalable.InfosetReader is an interface, and JAXB can't handle interfaces.
...............
Caused By: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
oracle.xml.scalable.InfosetReader is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at oracle.xml.scalable.InfosetReader
at public oracle.xml.scalable.InfosetReader oracle.xml.parser.v2.XMLDocument.getInfosetReader()
at oracle.xml.parser.v2.XMLDocument
at public oracle.xml.parser.v2.XMLDocument testws.jaxws.TestXML.arg0
at testws.jaxws.TestXML
oracle.xml.scalable.InfosetReader does not have a no-arg default constructor.
this problem is related to the following location:
at oracle.xml.scalable.InfosetReader
at public oracle.xml.scalable.InfosetReader oracle.xml.parser.v2.XMLDocument.getInfosetReader()
at oracle.xml.parser.v2.XMLDocument
at public oracle.xml.parser.v2.XMLDocument testws.jaxws.TestXML.arg0
at testws.jaxws.TestXML

I reported the issue to Oracle forum and found that JAXB could not marshal these classes and hence Jdeveloper pops this error. So currently either you can use classes that have default data bindings in JAXB or probably need to write your own binding file or as a workaround you can either use Object type.

Well if there are any other methods that are causing this issue and you do not intend to expose them as service (which wasn't my case), annotate these method by @WebMethod(exclude=true). Currently JDeveloper doesn't annotates by default but hopefully this functionality will be added in future (Bug 9749573 is already logged for this issue)

No comments:

Post a Comment