Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic