4 Replies Latest reply on Dec 9, 2008 1:16 AM by Frederic Wenzel

    UserBusinessActivity null pointer exception?

    Frederic Wenzel Newbie

      Hello,

      I am trying to build a very simple business activity (eventually crossing two JBoss instances). For now, I am having trouble starting and closing a business activity without *any* participants.

      I am running JBoss 5.0.0GA and I deployed the JBoss Transactions 4.4.0 SAR successfully. I compiled the xts-demo application, deployed it, and it runs fine as well.

      My code is very, very simple:

      package com.example.client;
      
      import com.arjuna.mw.wst.UserBusinessActivityFactory;
      import com.arjuna.mw.wst.UserBusinessActivity;
      
      public class TCheckClient {
       public static String startProposal() {
      
       UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
       uba.begin();
       uba.close();
       return "Success!";
       }
      }
      


      When I call this from a simple index.jsp file, I get the following error console output:
      15:51:06,715 INFO [TCheckClient] Starting proposal workflow
      15:51:06,734 ERROR [STDERR] java.lang.NullPointerException
      15:51:06,735 ERROR [STDERR] at com.example.client.TCheckClient.startProposal(TCheckClient.java:40)
      15:51:06,736 ERROR [STDERR] at org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
      15:51:06,737 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      15:51:06,738 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      15:51:06,738 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
      15:51:06,738 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
      15:51:06,738 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
      15:51:06,739 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      15:51:06,741 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      15:51:06,742 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      15:51:06,742 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      15:51:06,742 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      15:51:06,742 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      15:51:06,742 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      15:51:06,743 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      15:51:06,743 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      15:51:06,743 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      15:51:06,743 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      15:51:06,743 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      15:51:06,744 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      15:51:06,744 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      15:51:06,744 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      15:51:06,744 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      15:51:06,744 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      15:51:06,744 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
      15:51:06,745 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
      15:51:06,745 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      15:51:06,745 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      


      Line 40 is uba.begin().

      Apparently, something very fundamental is missing. But what? My application does contain the JBoss Transaction client JARs, my JBoss instance does have XTS deployed and working. Can somebody tell me what I am missing here?

      Thanks in advance!

        • 1. Re: UserBusinessActivity null pointer exception?
          Jonathan Halliday Master

          You probably have the wrong URLs in the config files. Being unable to find the necessary endpoints is the usual reason a begin will fail.

          • 2. Re: UserBusinessActivity null pointer exception?
            Andrew Dinn Master

            I think the problem may lie between these two statements:


            I am running JBoss 5.0.0GA and I deployed the JBoss Transactions 4.4.0 SAR successfully. I compiled the xts-demo application, deployed it, and it runs fine as well.



            Apparently, something very fundamental is missing. But what? My application does contain the JBoss Transaction client JARs, my JBoss instance does have XTS deployed and working. Can somebody tell me what I am missing here?


            First off I'll note that you may well be better off using AS 5.0 and the sar deployemt model. However, if your intention is still to use the BA framework then you are entering untested territory. That's not a recommendation to back off. I see no reason why the BA framework should work any less well with AS5.0 and the latest XTS than with the advertised versions that it was tested on. In fact quite the opposite. So, I'll be interested to hear whether it works.

            Now back to the possible point of contention. Previously I advised you that the old deployment model for AS 4.X was to bundle the XTS code with your app in an ear. Since you have switched to the new AS you must conform with its deployment model which makes the XTS code and services available via a sar deployed separate from your application. So, if you have deployed either the XTS code or the JTA/JTS libraries with your app in an ear then this will mean there are two copies of the XTS code which will cause serious headaches. So, if this is the case then unbundle these libraries and try again. If not then let me know and I will advise further.

            .


            • 3. Re: UserBusinessActivity null pointer exception?
              Frederic Wenzel Newbie

              Ouch! Thank you for pointing out the obvious. I did indeed have "leftover" JAR files in the build path, which led to the error. My userBusinessActivity is started as expected now, says my debug output:

              Client transaction ID: BusinessActivityIdentifier: urn:7f000101:a855:493db6d5:323


              Now, I have a JAX-WS web service and generated client stubs for it, and I can call it from the client, and inside the web service, I want it to join the business activity:

              package com.example.kit;
              
              import com.arjuna.mw.wst.BusinessActivityManager;
              import com.arjuna.mw.wst.BusinessActivityManagerFactory;
              
              @WebService
              public class Student {
               ...
              
               @WebMethod
               public int modifyProposal() throws Exception {
               BusinessActivityManager bam = BusinessActivityManagerFactory.businessActivityManager();
               log.info(bam.currentTransaction().toString());
               }
              }
              


              ... and once again, I get a NullPointerException, this time for the Business Activity Manager instance I am trying to request:

              java.lang.NullPointerException
               at com.example.kit.Student.modifyProposal(Student.java:68)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerJSE.invoke(InvocationHandlerJSE.java:99)
               at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:219)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:498)
               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:109)
               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 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:828)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Thread.java:595)
              00:07:30,139 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
              java.lang.NullPointerException
               at com.example.kit.Student.modifyProposal(Student.java:68)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerJSE.invoke(InvocationHandlerJSE.java:99)
               at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:219)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:498)
               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:109)
               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 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:828)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Thread.java:595)
              


              This time I am sure the right classes are being used, but do you have a guess where this problem could come from?

              Is it possible that the WS-BA headers are not injected in the SOAP message sent by the client and that's why it fails? If so, am I not allowed to use the JAX-WS client stubs generated by wsconsume then?

              Thanks for your input!

              • 4. Re: UserBusinessActivity null pointer exception?
                Frederic Wenzel Newbie

                Ah, looking at the JBossTS 4.4.0GA XTS demo app helped... Of course if I don't attach the context handlers, no SOAP headers will be modified.

                I added those and ta-dah, both the client and service are now aware of the same transaction.

                Registering the participant still fails, but I'll get there tomorrow.

                I appreciate your patience :)