5 Replies Latest reply on Feb 7, 2012 6:41 PM by sfcoy

    Howto install Axis2 on JBoss AS7?

    benze

      Hi,

       

      I've got a JAX-WS web service that does not seem to be compatible with the cxf stack that comes preinstalled/configured with JBoss7, but works with WebSphere/Axis2.  I am not sure why I am seeing this incompatibility as I am not using any Axis2 specific classes (am only using javax.ws classes), but none the less, I get class incompatibility issues.

       

       

      {code}

      11:39:02,121 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-0.0.0.0-0.0.0.0-8080-1) Application {http://www.com/ClientServices/LendingSimulation/V1.2}LendingSimulationService#{http://www.com/ClientServices/LendingSimulation/V1.2}calculateBorrowingData has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: org.apache.cxf.jaxws.context.WrappedMessageContext incompatible with javax.xml.ws.handler.soap.SOAPMessageContext

              at org.jboss.wsf.stack.cxf.JBossWSInvoker.createFault(JBossWSInvoker.java:234)

              at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:189)

              at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:117)

              at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)

              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452) [:6.0]

              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314) [:6.0]

              at java.util.concurrent.FutureTask.run(FutureTask.java:149) [:6.0]

              at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)

              at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)

              at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)

              at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)

              at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)

              at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91)

              at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:162)

              at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)

              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)

              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

              at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)

              at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:138) [jbossws-spi-2.0.0.Beta7.jar:2.0.0.Beta7]

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at java.lang.Thread.run(Thread.java:735) [:6.0]

      Caused by: java.lang.ClassCastException: org.apache.cxf.jaxws.context.WrappedMessageContext incompatible with javax.xml.ws.handler.soap.SOAPMessageContext

              at com.clientservices.lendingsimulation.util.SoapUtil.extractServiceContextFromHeader(SoapUtil.java:43) [classes:]

              at com.clientservices.lendingsimulation.service.LendingSimulationServiceImpl.calculateBorrowingData(LendingSimulationServiceImpl.java:112) [classes:]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:6.0]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45) [:6.0]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) [:6.0]

              at java.lang.reflect.Method.invoke(Method.java:599) [:6.0]

              at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)

              at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:169)

              ... 33 more

       

      {code}

       

      Class in question:

       

      {code}

      import javax.xml.bind.JAXBContext;

      import javax.xml.bind.JAXBException;

      import javax.xml.bind.Unmarshaller;

      import javax.xml.namespace.QName;

      import javax.xml.ws.WebServiceContext;

      import javax.xml.ws.handler.soap.SOAPMessageContext;

       

      public class SoapUtil{

       

                private static final String SECURITY_ELEMENT = "Security";

                private static final String SECURITY_HEADER_NS = "http://schemas.xmlsoap.org/ws/2002/xx/secext";

                private static final String SERVICE_CONTEXT_ELEMENT = "serviceContext";

                private static final String SERVICE_HEADERS_NS = "http://www.domain.ca/fw/serviceHeaders";

                private static final String JAXWS_BINDING_SOAP_HEADERS_INBOUND = "jaxws.binding.soap.headers.inbound";

                private static final Logger LOGGER = Logger.getLogger(SoapUtil.class);

       

      @SuppressWarnings("unchecked")

      public static ServiceContext extractServiceContextFromHeader(WebServiceContext webServiceContext) {

                SOAPMessageContext soapMessageContext = (SOAPMessageContext) webServiceContext.getMessageContext();

                Map<QName, List<String>> inboundHeaders = (Map<QName, List<String>>) soapMessageContext

                                    .get(JAXWS_BINDING_SOAP_HEADERS_INBOUND);

                ServiceContext serviceContext = null;

                if (!inboundHeaders.isEmpty()) {

                          List<String> elements = inboundHeaders.get(new QName(SERVICE_HEADERS_NS, SERVICE_CONTEXT_ELEMENT));

                          if (elements != null && !elements.isEmpty()) {

                                    String xmlServiceContext = elements.get(0);

                                    ByteArrayInputStream input = null;

                                    try {

                                              JAXBContext jc = JAXBContext.newInstance(ServiceContext.class);

                                              Unmarshaller u = jc.createUnmarshaller();

                                              input = new ByteArrayInputStream(xmlServiceContext.getBytes());

                                              serviceContext = (ServiceContext) u.unmarshal(input);

                                    } catch (JAXBException e) {

                                              LOGGER.error(ExceptionUtils.getStackTrace(e));

                                    } finally {

                                              IOUtils.closeQuietly(input);

                                    }

                          }

                }

                return serviceContext;

      }

      }

      {code}

       

      As you can see, I have no direct dependence on Axis2, which is why I was expecting that the service would work find with cxf, but apparently not.

       

      Without understanding too much why I am having these incompatibilities, I thought the easiest way would be to install the axis2 stack on JB7, but I cannot seem to find any instructions/documentation explaining how to configure AS7 to use Axis2.

       

      Can someone help me out please?


      Thanks,


      Eric

        • 1. Re: Howto install Axis2 on JBoss AS7?
          ctomc

          hi,

           

          you probably have some extra jar in your application that colides with system one.

           

          there are two solutions, either remove those jars with standard libs, or keep them and exclude application server modules for your deployment.

           

          for more info about how to do that read: https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

           

          cheers,

          tomaz

          • 2. Re: Howto install Axis2 on JBoss AS7?
            benze

            Thanks for the suggestion, but I've gone through all my jar files and didn't find javax.xml.ws.handler.soap.SOAPMessageContext anywhere.  Which is good, since it belongs to the JRE.  Which leads me to believe that there is an incompatibility between my the javax.xml.ws provided by my JRE (IBM JRE) and the CXF stack.

             

            Hence the desire to switch to Axis2 and see if that will work better.

             

            Thanks,


            Eric

            • 3. Re: Howto install Axis2 on JBoss AS7?
              ctomc

              hi,

               

              i would first try using oracle(sun) jdk 6 before trying anything else, as this is currently only full tested and functional jdk for running as7.

               

              you can read more about this here https://issues.jboss.org/browse/AS7-2166

               

              so please try with sun jdk.

               

              cheers,

              tomaž

              • 4. Re: Howto install Axis2 on JBoss AS7?
                benze

                Thanks, but that was the same result as well (both with Oracle JRE and JDK 6.0.29) :

                {code}

                 

                c61271b4@2UA1381DS5 /cygdrive/c/servers/jboss-as-7.0.2.Final/bin

                $ ./standalone.sh  --server-config=standalone-preview.xml

                =========================================================================

                  JBoss Bootstrap Environment

                  JBOSS_HOME: C:\servers\jboss-as-7.0.2.Final

                  JAVA: /cygdrive/c/Program Files/Java/jdk1.6.0_29/jre/bin/java

                  JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n -Djboss.bind.address=0.0.0.0

                =========================================================================

                 

                ........

                 

                 

                14:36:11,517 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-0.0.0.0-0.0.0.0-8080-1) Application {http://www.com/ClientServices/LendingSimulation/V1.2}LendingSimulationService#{http://www.com/ClientServices/LendingSimulation/V1.2}calculateBorrowingData has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: org.apache.cxf.jaxws.context.WrappedMessageContext cannot be cast to javax.xml.ws.handler.soap.SOAPMessageContext

                        at org.jboss.wsf.stack.cxf.JBossWSInvoker.createFault(JBossWSInvoker.java:234)

                        at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:189)

                        at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:117)

                        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)

                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_29]

                        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_29]

                        at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_29]

                        at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)

                        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)

                        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)

                        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)

                        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)

                        at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91)

                        at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:162)

                        at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)

                        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)

                        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)

                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                        at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)

                        at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:138) [jbossws-spi-2.0.0.Beta7.jar:2.0.0.Beta7]

                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                        at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                        at java.lang.Thread.run(Thread.java:662) [:1.6.0_29]

                Caused by: java.lang.ClassCastException: org.apache.cxf.jaxws.context.WrappedMessageContext cannot be cast to javax.xml.ws.handler.soap.SOAPMessageContext

                        at com.clientservices.lendingsimulation.util.SoapUtil.extractServiceContextFromHeader(SoapUtil.java:43) [classes:]

                        at com.clientservices.lendingsimulation.service.LendingSimulationServiceImpl.calculateBorrowingData(LendingSimulationServiceImpl.java:112) [classes:]

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_29]

                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_29]

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_29]

                        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_29]

                        at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)

                        at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:169)

                        ... 33 more

                 

                {code}

                 

                 

                And output of java -version:

                 

                {code}

                c61271b4@2UA1381DS5 /cygdrive/c/Program Files/Java/jdk1.6.0_29/jre/bin

                $ ./java -version

                java version "1.6.0_29"

                Java(TM) SE Runtime Environment (build 1.6.0_29-b11)

                Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)

                {code}

                • 5. Re: Howto install Axis2 on JBoss AS7?
                  sfcoy

                  I suspect this is a bug in your code.

                   

                  SOAPMessageContext is passed into implementations of  javax.xml.ws.handler.soap.SOAPHandler. It doesn't rate any other mention in the JAX-WS (2.1 & 2.2) spec.

                   

                  The fact that you get one of these from a call to WebServiceContext.getMessageContext in WebSphere/Axis2 was a (un)fortunate accident.

                   

                  I think that the header processing that you're doing should probably be done in a SOAPHandler.