Java中的XMLGregorianCalendar的NoClassDefFoundError

时间:2014-06-11 18:50:03

标签: java rest spring-mvc jaxb

我正在使用Java6,Apache Tomcat和Jersey RESTful。虽然将XML解组为JAXB,但我得到以下异常。任何人都可以帮我解决这个问题吗? 注意:此异常不一致。

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)

3 个答案:

答案 0 :(得分:3)

说明:新版本的java在jdk中有xerces lib。这个lib与apache的xerses lib冲突。 即使它说“没有上课”也是因为它有两个。 解决方案:检查项目是否属实,并从依赖项中删除其中一个并构建项目。

答案 1 :(得分:2)

我有,你在类路径中添加了xerces jar吗? 如果没有从xerces jar link下载并将其添加到项目类路径中。

请给我反馈。享受:)

答案 2 :(得分:2)

这是由于类路径中有多个xercesImpl.jar。这个jar可能来自你的应用程序,JDK和servlet容器。 POM的以下更改为我解决了这个问题。

<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>