SKC...
SKC...

Reputation: 223

NoClassDefFoundError for XMLGregorianCalendar in Java

I am using Java6,Apache Tomcat and Jersey RESTful. While unmarshelling the XML to JAXB, I am getting the following exception.Can any body help me on this ? Note: This Exception is inconsistent.

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser
     at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.<init>(Unknown Source)
     at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)
     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.parse(RuntimeBuiltinLeafInfoImpl.java:543)
     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.parse(RuntimeBuiltinLeafInfoImpl.java:517)
     at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:241)
     at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:61)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:462)
     at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.processText(StAXStreamConnector.java:367)
     at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:245)
     at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:214)
     at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
     at com.sun.xml.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:120)
     at com.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:233)
     at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.readRequest(EndpointArgumentsBuilder.java:517)
     at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$Composite.readRequest(EndpointArgumentsBuilder.java:188)
     at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:243)
     at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
     at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)
     at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)
     at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)
     at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)
     at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
     at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
     at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
     at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:134)
     at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:272)
     at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:185)
     at weblogic.wsee.jaxws.JAXWSServlet.doPost(JAXWSServlet.java:180)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
     at weblogic.wsee.jaxws.JAXWSServlet.service(JAXWSServlet.java:64)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
     at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
     at weblogic.security.service.SecurityManager.runAs(Unknown Source)
     at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
     at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

Upvotes: 1

Views: 18168

Answers (3)

vinod
vinod

Reputation: 39

This is due to multiple xercesImpl.jar in class path. This jar may be from your application, from JDK and from servlet container. Following changes in POM resolved this issue for me.

<dependency>
        <groupId>xerces</groupId>
        <artifactId>resolver</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>serializer</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <scope>provided</scope>
    </dependency>

Upvotes: 2

Alina_Lapina
Alina_Lapina

Reputation: 79

EXPLANATION: New versions of java have xerces lib in jdk. This lib conflict with apache's xerses lib. Even when it says "no class" it's because there are two of them. SOLUTION: Check if this is true for your project and remove one of them from the dependencies and build the project.

Upvotes: 3

jeorfevre
jeorfevre

Reputation: 2316

I have, you been adding xerces jar in your classpath ? If not download it from xerces jar link and add it to your project classpath.

Give me feedback please. enjoy :)

Upvotes: 3

Related Questions