aspose file tools*
The moose likes Web Services and the fly likes SAAJ - javax.xml.ws.WebServiceException: Unable to create JAXBContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "SAAJ - javax.xml.ws.WebServiceException: Unable to create JAXBContext" Watch "SAAJ - javax.xml.ws.WebServiceException: Unable to create JAXBContext" New topic
Author

SAAJ - javax.xml.ws.WebServiceException: Unable to create JAXBContext

Arun Adi
Greenhorn

Joined: Jan 18, 2012
Posts: 4

I have been trying to create a XML file from a Java Web service and create a SOAP message with Attachment using SAAJ to send it to another Web service. My Web service code is given below.
__________________________________________________________________________

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement(root);
document.appendChild(rootElement);
Element ele1 = document.createElement("ID");
ele1.appendChild(document.createTextNode(InstanceId));
rootElement.appendChild(ele1);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(document);
File file = new File("/CurrentStatus.xml");
StreamResult result = new StreamResult(file);
transformer.transform(source, result);
__________________________________________________________________________

On deploying this Web service, I get the following error.
javax.xml.ws.WebServiceException: Unable to create JAXBContext

__________________________________________________________________________

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 3
counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[]
java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at private java.lang.Throwable
Local.jaxws.TransformerConfigurationExceptionBean.exception
at Local.jaxws.TransformerConfigurationExceptionBean
javax.xml.transform.SourceLocator is an interface, and JAXB can't
handle interfaces.
this problem is related to the following location:
at javax.xml.transform.SourceLocator
at private javax.xml.transform.SourceLocator
Local.jaxws.TransformerConfigurationExceptionBean.locator
at Local.jaxws.TransformerConfigurationExceptionBean
javax.xml.transform.SourceLocator does not have a no-arg default constructor.
this problem is related to the following location:
at javax.xml.transform.SourceLocator
at private javax.xml.transform.SourceLocator
Local.jaxws.TransformerConfigurationExceptionBean.locator
at Local.jaxws.TransformerConfigurationExceptionBean
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:438)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:286)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:105)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:153)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:149)
... 20 more
Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException:
Deployment Error -- Exception occured in the wsgen process
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.enterprise.webservice.WsUtil.runWsGen(WsUtil.java:1848)
at com.sun.enterprise.webservice.WsUtil.genWSInfo(WsUtil.java:2249)
at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:427)
at com.sun.enterprise.deployment.backend.WebModuleDeployer.deploy(WebModuleDeployer.java:160)
at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:182)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:208)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:283)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:835)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:225)


deployment started : 0%
Deploying application in domain failed; Deployment Error -- Exception
occured in the wsgen process javax.xml.ws.WebServiceException: Unable
to create JAXBContext
BUILD FAILED (total time: 3 seconds)

__________________________________________________________________________

I have tried adding javax.jar and other relevant jar files to the Web application libraries but of no use.

Any help to fix this problem would be very useful for me.

Thanks in advance.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
For a complete example, see section 5.7 of my book on web services, which you can download here:
http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
If you want further help with your code, please supply complete, runnable, code.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAAJ - javax.xml.ws.WebServiceException: Unable to create JAXBContext