What example should I look at when trying to create a WS-AT WebService based on a Stateless Session Bean with JBoss 7.1?
mrjazzy Sep 13, 2013 3:53 PMThe RestaurantServiceATImpl sample from the quick starts for JBoss 7.1 uses an approach based around a servlet and HandlerChains
@WebService(serviceName = "RestaurantServiceATService", portName = "RestaurantServiceAT", name = "RestaurantServiceAT", targetNamespace = "http://www.jboss.org/jboss-jdf/jboss-as-quickstart/wsat/simple/Restaurant")
@HandlerChain(file = "/context-handlers.xml", name = "Context Handlers")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebServlet("/RestaurantServiceAT")
uses an approach based on @Stateless
@Transactional //By default bridge from WS-AT to JTA
@Stateless
@Remote(RestaurantServiceAT.class)
@WebService(serviceName = "RestaurantServiceATService", portName = "RestaurantServiceAT", name = "RestaurantServiceAT", targetNamespace = "http://www.jboss.org/narayana/quickstarts/wsat/simple/Restaurant")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@TransactionAttribute(TransactionAttributeType.MANDATORY) // default is REQUIRED
public class RestaurantServiceATImpl implements RestaurantServiceAT {
I changed JBoss to start using the standalone-xts.xml from jboss-as-7.1.1.Final\docs\examples\configs
I tried an approach based on the later uses dependencies
<dependency>
<groupId>org.jboss.narayana</groupId>
<artifactId>jbosstxbridge</artifactId>
<version>5.0.0.M4</version>
<scope>provided</scope>
....
Which deployed fine
I then created a servlet to call the service ;
S24Server service1 = new S24ServerService(new URL("http://localhost:8080/BLEJB1/S24server1?wsdl"), new QName("http://ssb.ee.s24.test.uk/", "S24serverService")).getS24ServerPort();
S24Server service2 = new S24ServerService(new URL("http://localhost:8080/BLEJB1/S24server2?wsdl"), new QName("http://ssb.ee.s24.test.uk/", "S24serverService")).getS24ServerPort();
{
BindingProvider bindingProvider = (BindingProvider) service1;
List<Handler> handlers = new ArrayList<Handler>(1);
handlers.add(new JaxWSTxOutboundBridgeHandler());
handlers.add(new JaxWSHeaderContextProcessor());
bindingProvider.getBinding().setHandlerChain(handlers);
}
{
BindingProvider bindingProvider = (BindingProvider) service2;
List<Handler> handlers = new ArrayList<Handler>(1);
handlers.add(new JaxWSTxOutboundBridgeHandler());
handlers.add(new JaxWSHeaderContextProcessor());
bindingProvider.getBinding().setHandlerChain(handlers);
}
It deploys OK but when I run it I get the following exception
java.lang.ClassNotFoundException: org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler from [Module "deployment.BLEJBTestWeb.war:main" from Service Module Loader]
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
uk.test.s24.ee.web.TestServlet.doPost(TestServlet.java:65)
uk.test.s24.ee.web.TestServlet.doGet(TestServlet.java:52)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
Do I need to update the JBoss AS7 config I have to include narayana 5.0.0.M4 since I am running outside of Arquillian? Please could you direct me to a document to do this.
Or do I have to return to the previous @HandlerChain approach? And will this work on a @Stateless Bean ( I have tried but encountered other class loader problems )
Okay, so AS7 is using a version of the tx bridge and ts at 4.16.2 so it looks like the new approach won't work.
So I have moved back to the @HandlerChain approach (will this work with @Stateless @WebService?)
I set the dependency as follows;
<dependency>
<groupId>org.jboss.jbossts</groupId>
<artifactId>jbossxts-api</artifactId>
<version>4.16.2.Final</version>
<scope>provided</scope>
</dependency>
and have an SSB
@WebService(targetNamespace="")
//@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@Stateless
@Remote(S24Remote.class)
@Local(S24Local.class)
@HandlerChain(file = "/context-handlers.xml")
//@Transactional //By default bridge from WS-AT to JTA
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class S24server implements S24Remote, S24Local {
using the quickstart handler chain descriptor file;
<handler-chains 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">
<handler-chain>
<handler>
<handler-name>ContextHandler</handler-name>
<handler-class>com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor</handler-class>
</handler>
</handler-chain>
</handler-chains>
This is packaged as an ejb inside an EAR ( maybe this is the problem? - poms attached)
When I try and deploy I get
java.lang.ClassNotFoundException: com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor from [Module "deployment.BLEJB1EAR.ear.BLEJB1.jar:main" from Service Module Loader]
Thanks