Topic
6 replies Latest Post - ‏2013-04-04T14:42:10Z by SystemAdmin
SystemAdmin
SystemAdmin
590 Posts
ACCEPTED ANSWER

Pinned topic java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

‏2013-03-28T22:03:18Z |
I get this following exception when I try to call my JAXWS Web Service API

com.ibm.ws.webcontainer.util.ApplicationErrorUtils E SRVE0777E: Exception thrown by application class 'com.ibm.xml.xlxp2.jaxb.marshal.impl.SerializationStub.createElementContentChoiceMap:556'
java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl
at com.ibm.xml.xlxp2.jaxb.marshal.impl.SerializationStub.createElementContentChoiceMap(SerializationStub.java:556)
at com.ibm.xml.xlxp2.jaxb.marshal.codegen.fcg.FCGSerializationStubGenerator.generateElementContentChoiceMap(FCGSerializationStubGenerator.java:580)
at com.ibm.xml.xlxp2.jaxb.marshal.codegen.fcg.FCGSerializationStubGenerator.generateInitializeElementChoiceFields(FCGSerializationStubGenerator.java:462)
at com.ibm.xml.xlxp2.jaxb.marshal.codegen.fcg.FCGSerializationStubGenerator.generateInitializeMethod(FCGSerializationStubGenerator.java:331)
at com.ibm.xml.xlxp2.jaxb.marshal.codegen.fcg.FCGSerializationStubGenerator.generate(FCGSerializationStubGenerator.java:135)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.generateByteCode(AbstractGeneratedStubFactory.java:100)
at com.ibm.xml.xlxp2.jaxb.marshal.codegen.fcg.FCGStubFactory.generateStubByteCode(FCGStubFactory.java:44)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.getStubClassConstructor0(AbstractGeneratedStubFactory.java:159)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.getStubClassConstructor(AbstractGeneratedStubFactory.java:114)
at com.ibm.xml.xlxp2.jaxb.marshal.codegen.AbstractGeneratedSerializationStubFactory.createStub(AbstractGeneratedSerializationStubFactory.java:56)
at com.ibm.xml.xlxp2.jaxb.marshal.impl.SerializationContext.getSerializationStub(SerializationContext.java:161)
at com.ibm.xml.xlxp2.jaxb.marshal.impl.SerializationContext.getSerializationStub(SerializationContext.java:169)
at com.ibm.tscc.rtss.storage.ws.PolicyDocument_JAXB_Serialization_Stub.write(com.ibm.tscc.rtss.storage.ws.PolicyDocument_JAXB_Serialization_Stub.java)
at com.ibm.tscc.rtss.storage.ws.Policy_JAXB_Serialization_Stub.write(com.ibm.tscc.rtss.storage.ws.Policy_JAXB_Serialization_Stub.java)
at com.ibm.tscc.rtss.storage.ws.GetPolicyResponse_JAXB_Serialization_Stub.write(com.ibm.tscc.rtss.storage.ws.GetPolicyResponse_JAXB_Serialization_Stub.java)
at com.ibm.xml.xlxp2.jaxb.marshal.JAXB_Serialization_Root_Stub.write(com.ibm.xml.xlxp2.jaxb.marshal.JAXB_Serialization_Root_Stub.java)
at com.ibm.xml.xlxp2.jaxb.marshal.MarshallerImpl.marshal(MarshallerImpl.java:165)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:566)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:236)
at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:183)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)
at com.ibm.ws.jaxws.web.POJOJaxWsWebEndpoint.invoke(POJOJaxWsWebEndpoint.java:114)
at com.ibm.ws.jaxws.webcontainer.LibertyJaxWsServlet.handleRequest(LibertyJaxWsServlet.java:135)
at com.ibm.ws.jaxws.webcontainer.LibertyJaxWsServlet.doPost(LibertyJaxWsServlet.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at com.ibm.ws.jaxws.webcontainer.LibertyJaxWsServlet.service(LibertyJaxWsServlet.java:86)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:758)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:441)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1041)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:78)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:867)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:252)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:531)
at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
at com.ibm.ws.threading.internal.Worker.run(Worker.java:421)
at java.lang.Thread.run(Thread.java:736)
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.dom.ElementImpl
at java.lang.ClassNotFoundException.<init>(ClassNotFoundException.java:76)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:425)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
... 43 more
The org.apache.xerces.dom package is not exported by any bundle in Liberty.
I attempted to add the eclipse bundle org.apache.xerces as a user feature to try to make the package org.apache.xerces.dom available and it is available when the server start but it doesn't help.
Does anybody run into this problem or have any idea about this error?

Any help would be greatly appreciated.

Thanks,
An
  • SystemAdmin
    SystemAdmin
    590 Posts
    ACCEPTED ANSWER

    Re: java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

    ‏2013-03-29T14:50:07Z  in response to SystemAdmin
    I also found this problem is similar (if not exact) the problem posted here for Tradition WAS -
    http://www-01.ibm.com/support/docview.wss?uid=swg1PM41292

    Is it by any chance a similar bug in Liberty related to JAXB classloader described in the link above?
  • Jacek_Laskowski
    Jacek_Laskowski
    133 Posts
    ACCEPTED ANSWER

    Re: java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

    ‏2013-03-29T20:35:56Z  in response to SystemAdmin
    Hi,

    How did you create the web service? I've just created a simple one with @WebService and it did work fine.

    Jacek
    Japila :: verba docent, exempla trahunt
    • SystemAdmin
      SystemAdmin
      590 Posts
      ACCEPTED ANSWER

      Re: java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

      ‏2013-03-31T05:04:51Z  in response to Jacek_Laskowski
      Hi Jacek,
      Thank you for responding.

      I didn't create the WS for Liberty specifically. It was one that works in Traditional WAS. I was just trying to port it to run on Liberty.
      Does your WS involve with any XML serialization with complex type?
      Anyhow, there are other WS APIs that work fine for the same Web Service.
      The problem only arises when there involved complex type where the content returned contains nesting XML.
      The error occurs when it tried to marshall jaxb object.

      I had a utility class to find which jar the class above was loaded from , called it from the WS implementation code and it came back with the JVM xml.jar.
      From this, it doesn't look like the JAXB marshall API has access to the org.apache.xerces.dom.ElementImpl class which is a part of the JAXB implementation class.
      Thanks,
      An
      • Jacek_Laskowski
        Jacek_Laskowski
        133 Posts
        ACCEPTED ANSWER

        Re: java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

        ‏2013-03-31T07:32:42Z  in response to SystemAdmin
        Hi,

        It's getting more and more interesting...

        Could you give me some more pointers as to how recreate the issue in my environment? How should I change the following code so it reflects yours?
        
        
        
        package ibm;   
        
        import javax.jws.WebService;   @WebService 
        
        public 
        
        class HelloJaxWs 
        { 
        
        public String hello() 
        { 
        
        return 
        "Hello from JAX-WS"; 
        } 
        }
        


        Jacek
        Japila :: verba docent, exempla trahunt
        • SystemAdmin
          SystemAdmin
          590 Posts
          ACCEPTED ANSWER

          Re: java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

          ‏2013-04-02T04:46:16Z  in response to Jacek_Laskowski
          Hi Jacek,
          You can recreate the problem by creating a schema with a complex type "any" .
          For example:
          ---
          <xs:complexType name="testXMLDoc">
          <xs:sequence>
          <xs:any minOccurs="0" namespace="##other" processContents="lax"/>
          </xs:sequence>
          </xs:complexType>
          ----
          Note that our shema is much more complicated than this, but I believe this will do for the purpose of recreation.

          The generated code contains:
          /**
          *

          Java class for testXMLDoc complex type.
          *
          *

          The following schema fragment specifies the expected content contained within this class.
          *
          *

           * <complexType name="testXMLDoc">
          * <complexContent>
          * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
          * <sequence>
          * <any/>
          * </sequence>
          * </restriction>
          * </complexContent>
          * </complexType>
          *
          *
          *
          */
          @XmlAccessorType(XmlAccessType.FIELD)
          @XmlType(name = "testXMLDoc", namespace = "http://test.XML.doc/", propOrder = {
          "any"
          })
          public class TestXMLDoc {

          @XmlAnyElement(lax = true)
          protected Object any;

          /**
          * Gets the value of the any property.
          *
          * @return
          * possible object is
          * {@link Object }
          * {@link Element }
          *
          */
          public Object getAny() {
          return any;
          }

          /**
          * Sets the value of the any property.
          *
          * @param value
          * allowed object is
          * {@link Object }
          * {@link Element }
          *
          */
          public void setAny(Object value) {
          this.any = value;
          }

          }

          Add a API to your Web Service to return the TestXMLDoc where the content of the any is an SOAPElement.

          BTW, some more findings on problem - the content-type header makes a different with curl command.
          A curl command for the same operation return successfully with the following content-type:
          "Content-type: application/xml;charset=us-ascii" works
          "Content-type: text/xml" works
          However curl command for the same operation fails for the following content-type:
          "Content-type: text/xml;charset=UTF-8" ; doesn't work
          "Content-type: application/xml;charset=UTF-8" ; doesn't work
          Programmatically setting the content type is not yet achievable.
          Any idea?

          Thanks,
          An



  • SystemAdmin
    SystemAdmin
    590 Posts
    ACCEPTED ANSWER

    Re: java.lang.NoClassDefFoundError: org.apache.xerces.dom.ElementImpl

    ‏2013-04-04T14:42:10Z  in response to SystemAdmin
    I moved up to Beta 2, ran into similar problem posted by Yusuf here
    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=480974&tstart=0

    Use his work around by exposing the "unexposed" eclipse core package and got my application started
    and the jaxb NoClassDefFoundError went away.

    Thanks,
    An