title: Exception occurs while running both AXIS2 services and JAXWS services in the same application and same server
body: <p>To do a POC, I have a wrote a JAXWS class in the same package used for AXIS-2 services and configured that class in web.xml (content pasted below)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
   &lt;display-name&gt;Apache-Axis2&lt;/display-name&gt;
   &lt;servlet&gt;
    &lt;servlet-name&gt;AxisServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.apache.axis2.transport.http.AxisServlet&lt;/servlet-class&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
   &lt;/servlet&gt;
   &lt;servlet&gt;
    &lt;servlet-name&gt;PocServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.poc.PocJaxWS&lt;/servlet-class&gt;
    &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
   &lt;/servlet&gt;
   &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;AxisServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/services/*&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
   &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;PocServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/poc&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
   &lt;/web-app&gt;
  </code></pre>
  
  <p>After starting my server, i was able to generatel wsdl. But when i sent a sample request from soap-ui, i was getting many runTimeExceptions (exception log pasted below)</p>
  
  <pre><code>javax.xml.soap.SOAPException: java.lang.IllegalStateException: Failed to load javax.xml.soap.SOAPFactory: org.apache.axis2.saaj.SOAPFactoryImpl
      at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:65)
      at org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(SOAPFactoryImpl.java:121)
      at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:136)
      at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:96)
      at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:294)
      at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:193)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:455)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
      at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.hmco.ssms.common.hibernate.HibernateUtil.doFilter(HibernateUtil.java:124)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.IllegalStateException: Failed to load javax.xml.soap.SOAPFactory: org.apache.axis2.saaj.SOAPFactoryImpl
      at javax.xml.soap.SAAJFactoryLoader.loadFactory(SAAJFactoryLoader.java:128)
      at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:61)
      ... 34 more
  Caused by: java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.axis2.saaj.SOAPFactoryImpl.createElement(Ljavax/xml/namespace/QName;)Ljavax/xml/soap/SOAPElement;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/apache/axis2/saaj/SOAPFactoryImpl, and its superclass loader (instance of &lt;bootloader&gt;), have different Class objects for the type javax/xml/namespace/QName used in the signature
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
      at java.lang.Class.getConstructor0(Class.java:2699)
      at java.lang.Class.newInstance0(Class.java:326)
      at java.lang.Class.newInstance(Class.java:308)
      at javax.xml.soap.SAAJFactoryLoader.loadFactory(SAAJFactoryLoader.java:123)
      ... 35 more
  2012-03-14 17:01:23,358 ERROR [org.jboss.wsf.stack.jbws.RequestHandlerImpl] (http-127.0.0.1-8080-1) Error processing web service request
  org.jboss.ws.WSException: java.lang.ClassCastException: org.apache.axis2.saaj.MessageFactoryImpl cannot be cast to org.jboss.ws.core.soap.MessageFactoryImpl
      at org.jboss.ws.WSException.rethrow(WSException.java:68)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:336)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
      at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.hmco.ssms.common.hibernate.HibernateUtil.doFilter(HibernateUtil.java:124)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.ClassCastException: org.apache.axis2.saaj.MessageFactoryImpl cannot be cast to org.jboss.ws.core.soap.MessageFactoryImpl
      at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.createSOAPMessage(SOAPFaultHelperJAXWS.java:288)
      at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toSOAPMessage(SOAPFaultHelperJAXWS.java:256)
      at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:187)
      at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:102)
      at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:671)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:496)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
      ... 27 more
  </code></pre>
  
  <p>Please help me on this. Is this because of running both AXIS and JAXWS in the same app ? or is there any configuration to overcome this ??</p>
  
  <p>Regards
  Arun</p>