4 Replies Latest reply on Sep 17, 2013 5:40 AM by paul.robinson

    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

      The 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")

       

       

      The latest from https://github.com/jbosstm/quickstart/blob/master/XTS/jta-over-wsat/src/main/java/org/jboss/narayana/quickstarts/wsat/jta/RestaurantServiceATImpl.java

      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

        • 1. Re: 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

          Sorry this is not a clear question.

           

          I shall answer part of it myself (User Error) and then resubmit  a new clearer question...

           

          The class not found problem with 4.16.2.Final was because I had omitted the dependencies section for the WAR/EAR manifest in the ear/war plugin in the POM;

           

          <build>

          <plugin>

                  <artifactId>maven-war-plugin</artifactId>

                  <version>2.3</version>

                  <configuration>

                    <warSourceDirectory>WebContent</warSourceDirectory>

                    <failOnMissingWebXml>false</failOnMissingWebXml>

                    <archive>

                       <manifestEntries>

                           <Dependencies>org.jboss.xts</Dependencies>

                        </manifestEntries>

                    </archive>

                  </configuration>

                </plugin>

          ...

          1 of 1 people found this helpful
          • 2. Re: What example should I look at when trying to create a WS-AT WebService based on a Stateless Session Bean with JBoss 7.1?
            paul.robinson

            John,

             

            You need to use the same version of the Narayana quickstarts, as the version of Narayana (rename of JBossTS for 4.17 onwards) running inside the application server. You can get the tagged quickstarts from here: https://github.com/jbosstm/quickstart/releases . However, this was only done from 4.17 onwards when we moved to Git. For versions prior to 4.17, the quickstarts where embedded in the source tree of JBossTS. The code was also in SVN in those days: labs - Revision 38410: /labs/jbosstm/tags

             

            Also, I suspect you want to distribute your transactions over Web Services (via WS-AT) and then use JTA transactions in your session bean to enlist resources such as an XA database or message server? If this is the case, the quickstart in JDF is not going to help as it does not cover the bridging of WS-AT to JTA. I suggest you look at the TXBride quickstart here: labs - Revision 38410: /labs/jbosstm/tags/JBOSSTS_4_16_2_Final/txbridge/demo. This is actually easier to code than the JDF example and also uses a Stateless Session bean, as per your requirements.

             

            The quickstarts you saw in our master branch simplifies a lot of the boiler-plate code you have to produce. It will also (today or tomorrow), automatically setup the XTS dependencies, so you wouldn't have had to add the manifest entry. However, these improvements are only available in WildFly 8 (the successor to JBoss AS 7).

             

            Please let me know if you have any problems,

             

            Paul.

            • 3. Re: 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

              Thanks.

              Jboss's maintained examples are something which make it stand out in this area.

              I now have WS-AT working with my SSB.

              I have however got problems when two XA datasources in different beans are involved in the WS-AT transaction. My example works when invoked by a pojo using a standard SSB client (outside of the ACC)  but not when I use WS-AT from a servlet. I will submit another question with the sources to make things clearer.

              Thanks again.

              • 4. Re: What example should I look at when trying to create a WS-AT WebService based on a Stateless Session Bean with JBoss 7.1?
                paul.robinson

                John Francis wrote:

                 

                Jboss's maintained examples are something which make it stand out in this area.

                Fantastic. I'm glad you are finding them to be useful.

                 

                I now have WS-AT working with my SSB.

                I have however got problems when two XA datasources in different beans are involved in the WS-AT transaction. My example works when invoked by a pojo using a standard SSB client (outside of the ACC)  but not when I use WS-AT from a servlet. I will submit another question with the sources to make things clearer.

                Thanks again.

                Glad you have the basics working. I'll keep an eye out for your new question, regarding the more complex scenario.

                 

                Paul.