Howto install Axis2 on JBoss AS7?
benze Feb 7, 2012 11:44 AMHi,
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