6 Replies Latest reply on May 20, 2005 3:26 PM by hritcu

    JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues

    hr_stoyanov

      Thomas and all-,
      I am trying to use JAXB/JAXRPC 2.0 EA within the latest JBoss 4.0.2 under J2SE 5.0 Update_2. I get a weird exception, when a client tries to access my endpoint (see below). I did provide a jboss-web.xml file according to the wiki, to make sure I fully isolated myself from the old JBossWS/Axis stuff. Yet, I still get the same exception. Which makes me believe that JBoss 4 overrides the J2SE 5.0 built-in JAXP classes with incompatible ones somehow!!! Is this a correct assumption and how do I solve it (bundle jaxp jar)?

      Note that someone else posted the same problem in the JAXRPC/JAXB 2.0 forum at http://community.java.net/java-ws-xml/

      The problem DOES NOT EXIST IN TOMCAT 5.5.x, when used stand-alone.

      Find enlosed my jboss-web.xml and exception trace below,
      Thanks
      ------------------------------jboss-web.xml------------------------------------
      <?xml version="1.0" ?>
      <jboss-web>
      <class-loading java2ClassLoadingCompliance="false">
      <loader-repository>
      com.blabla:loader=efe_web_services_loader
      <loader-repository-config>
      java2ParentDelegation=false
      </loader-repository-config>
      </loader-repository>
      </class-loading>
      </jboss-web>
      ----------------------------- Exception ------------------------------------------
      JAXRPCContextListener contextInitialized
      INFO: JAXRPCSERVLET12: JAX-RPC context listener initializing
      15:09:42,094 INFO [STDOUT] May 10, 2005 3:09:42 PM com.sun.xml.rpc.server.http.
      JAXRPCServletDelegate init
      INFO: JAXRPCSERVLET14: JAX-RPC servlet initializing
      15:09:48,141 INFO [STDOUT] May 10, 2005 3:09:48 PM com.sun.xml.rpc.server.http.
      JAXRPCServletDelegate doPost
      SEVERE: caught throwable
      java.lang.NoSuchMethodError: javax.xml.parsers.SAXParserFactory.getSchema()Ljava
      x/xml/validation/Schema;
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.(SAXParse
      rImpl.java:124)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXPa
      rser(SAXParserFactoryImpl.java:98)
      at com.sun.xml.messaging.saaj.util.ParserPool.get(ParserPool.java:42)
      at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(Envelo
      peFactory.java:59)
      at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelope
      FromSource(SOAPPart1_1Impl.java:47)
      at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl
      .java:86)
      at com.sun.xml.messaging.saaj.soap.MessageImpl.getSOAPHeader(MessageImpl

        • 1. Re: JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues
          hr_stoyanov

          Okay-,
          It turns out, with J2SE 5.0, the $jboss-xxx/lib/endorsed really needs to be removed, since all the XML stuff (JAXP 1.3) is already an integral part of J2SE 5.0

          If you do not do that, JBoss will load the old JAXP stuff over the one endorsed in J2SE 5.0 itself. And bad things will happen if your applications depend on certain enhancements in J2SE 5.0 JAXP.

          Other than that, the server runs fine with the J2SE5.0 xml jars.

          I wonder if this has been documented somewhere?

          Does any one know the steps to completely remove JBossWS (in terms of jars to be killed, xml files to be edited)

          Thanks in advance,
          Hristo

          • 2. Re: JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues

             

            Other than that, the server runs fine with the J2SE5.0 xml jars.


            Have you actually managed to do that?

            I'm running JBoss 4.0.1SP1 with J2SE 5.0 and I'm having big problems because of the JAXP 1.3 and JBoss incompatibilities.

            Some of my classes heavily rely on DOM L3 and they won't run under the default settings of JBoss (and its old endorsed parser). They run just fine with the JAXP 1.3 parser in Java 5.0 so I tried to get rid of the endorsed directory.

            Unfortunately just removing it won't help as the JAXP 1.3 classes are not added to the classpath by default. I tried to add %JAVA_HOME%\jre\lib\rt.jar to the classpath but this still doesn't fix the problem. I sill get a lot errors and the most interesting one is

            java.lang.NoClassDefFoundError: org/apache/xerces/xni/parser/XMLEntityResolver


            When I had a look at rt.jar the path is now com/sun/org/apache/xerces/internal/xni/parser/XMLEntityResolver.class. So, it looks like JAXP1.2 and JAXP1.3 are not very compatible.

            Does anybody have a clue on how to make JBoss work with JAXP1.3 ?


            • 3. Re: JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues

              Trying to hack past the NoClassDefFoundError I also added the contents of the endorsed directory to the classpath (after removing the -Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" and adding rt.jar to the classpath)

              %JBOSS_HOME%\lib\endorsed\xercesImpl.jar;
              %JBOSS_HOME%\lib\endorsed\resolver.jar;
              %JBOSS_HOME%\lib\endorsed\xalan.jar;
              %JBOSS_HOME%\lib\endorsed\xml-apis.jar
              


              Well, this made Jboss start without errors but it has not solved my problem. I'm still getting the same error as before when I try to perform some DOM L3 functions:

              2005-05-19 10:51:01,765 ERROR [org.jboss.ejb.plugins.LogInterceptor] Unexpected Error in method: public abstract void net.sf.adf.transport.JMSTransportRemote.send(net.sf.adf.acl.ACLMessage) throws net.sf.adf.transport.SendingException,java.rmi.RemoteException
              java.lang.AbstractMethodError: org.apache.xml.serialize.DOMSerializerImpl.getDomConfig()Lorg/w3c/dom/DOMConfiguration;
               at net.sf.adf.acl.xml.XMLCodec.encode(XMLCodec.java:63)
               at net.sf.adf.transport.JMSTransport.send(JMSTransport.java:133)
               at net.sf.adf.transport.JMSTransport.send(JMSTransport.java:119)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
               at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
               at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
               at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
               at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
               at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
               at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
               at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
               at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
               at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
               at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
               at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
               at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
               at org.jboss.ejb.Container.invoke(Container.java:870)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
               at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
               at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
               at sun.rmi.transport.Transport$1.run(Transport.java:153)
               at java.security.AccessController.doPrivileged(Native Method)
               at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
               at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
               at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
               at java.lang.Thread.run(Thread.java:595)
              


              The code that causes this exception is this:
               public String encode(ACLMessage message) throws EncodingException {
               Document doc = encodeDOM(message);
               try {
               DOMImplementationLS domImplLS = (DOMImplementationLS)doc.getImplementation();
              
               StringWriter sw = new StringWriter();
               LSOutput output = domImplLS.createLSOutput();
               output.setCharacterStream(sw);
              
               LSSerializer serializer = domImplLS.createLSSerializer();
               DOMConfiguration config = serializer.getDomConfig();
              


              All I'm trying to do is run some valid Java 5.0 code in JBoss ... could you please give me a hand with this.


              • 4. Re: JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues

                In the end I managed to make it work by adding one final touch to the solution described above. Instead of the arguably more portable way of obtaining a DOMImplementation:

                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                DOMImplementation domImpl = builder.getDOMImplementation();
                


                I directly used the DOMImplementation from JDK1.5, that is:
                DOMImplementation domImpl = (DOMImplementation)com.sun.org.apache.xerces
                .internal.dom.DOMImplementationImpl.getDOMImplementation();
                


                This is not a nice solution, but it was the best I could find on my own. If you have a more elegant I would be interested in finding out about it.

                In both cases I had to make sure that the DOMImplementation supports LS 3.0:
                 if (!domImpl.hasFeature("LS", "3.0")) {
                 throw new ParserConfigurationException(
                 "Load/Save 3.0 not supported");
                 }
                


                and finally I used it to create new documents:
                Document doc = domImpl.createDocument(namespaceURI, rootElementQualifiedName, docType);
                

                cast it to a DOMImplementationLS and parse existing ones:
                 DOMImplementationLS domImplLS = (DOMImplementationLS)domImpl;
                
                 LSInput input = domImplLS.createLSInput();
                 input.setCharacterStream(reader);
                 LSParser parser = domImplLS.createLSParser(
                 DOMImplementationLS.MODE_SYNCHRONOUS,
                 validating ? "http://www.w3.org/TR/REC-xml" : null);
                 // for schema validation this would be set to
                 // "http://www.w3.org/2001/XMLSchema"
                 parser.getDomConfig().setParameter("validate", validating);
                 Document doc = parser.parse(input);
                

                or serialize in-memory DOM trees:
                 DOMImplementationLS domImplLS = (DOMImplementationLS)doc.getImplementation();
                
                 LSOutput output = domImplLS.createLSOutput();
                 output.setCharacterStream(writer);
                
                 LSSerializer serializer = domImplLS.createLSSerializer();
                 serializer.write(doc, output);
                


                There are many people who don't have the slightest idea all these are possible using only standard DOM and it's very good JDK1.5 implementation. It is a pity that JBoss is still shipping with a hard-wired full-of-bugs old implementation of Xerces when JAXP 1.3 works great.


                • 5. Re: JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues
                  hr_stoyanov

                  Sorry-,
                  ... for not paying attention tothis forum. I posted the solution to the JAX-RPC/JAXB 2.0 forum at java.net. Here is a copy of it:
                  ---------------------------------------------

                  I kind of did that and it appears to work, so here are the steps:

                  1) Remove the JAXP jars from ${jboss_home}/lib/endorsed
                  These are the old ones and seems like JAXRPC 2.0 EA will only work with JAXP 1.3, integral part of J2SE 5.0 now

                  2) Remove ${jboss_home}/server/<your_deployment>/lib/{jboss-saaj|jboss-ws4ee|jboss-jaxrpc}.jar

                  3) Copy all the stuff from ${jaxrpc2.0_home}/lib to the above lib folder. Now you do not have to bundle JAXRPC2.0 jars into your wars.

                  Here is portion of an ANT script I use to do that:

                  -------------------------------------------------
                  Remove your previous '${jboss.config}' configuration ...


                  Remove legacy JAXP jars from JBoss 4 ...









                  Clone JBoss default configuration into '${jboss.config}'...


                  <!-- Skip legacy WS jars -->




                  <!-- Skip Hipersonic database stuf -->
                  <!-- -->



                  Configure JAXRPC 2.0 into '${jboss.config}'...



                  --------------------------------------------------------

                  • 6. Re: JAXB/JAXRPC 2.0 EA in JBoss 4.0.2 blues

                     

                    I posted the solution to the JAX-RPC/JAXB 2.0 forum at java.net. Here is a copy of it


                    Well, it looks pretty messed up. Here is your original:

                    http://forums.java.net/jive/thread.jspa?threadID=688&tstart=0