5 Replies Latest reply on Jan 7, 2008 6:40 AM by Andrew Dinn

    problems with UserTransactionFactory.userTransaction();

    bryan borg Newbie

      Hi all,

      I am trying to implement my own code similar to the xts-demo. When i try to obtain a new transaction:

      
      UserTransaction ut = UserTransactionFactory.userTransaction();
      
      


      the UserTransaction returned is null and consequently when this line of code is executed:

      
      ut.begin();
      
      


      i get a null pointer exception:

      
      13:26:30,171 INFO [STDOUT] CLIENT: starting the transaction...
      13:26:30,171 ERROR [STDERR] java.lang.NullPointerException
      13:26:30,171 ERROR [STDERR] at com.thesis.wscoordination.servlets.BasicClient.testAtomicTransaction(Unknown Source)
      13:26:30,171 ERROR [STDERR] at com.thesis.wscoordination.servlets.BasicClient.test(Unknown Source)
      13:26:30,171 ERROR [STDERR] at com.thesis.wscoordination.servlets.BasicClient.doGet(Unknown Source)
      13:26:30,171 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      13:26:30,171 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      13:26:30,171 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      13:26:30,171 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      13:26:30,171 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      13:26:30,171 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      13:26:30,171 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      13:26:30,171 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      13:26:30,171 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      13:26:30,171 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      13:26:30,171 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      
      



      Any ideas please?

        • 1. Re: problems with UserTransactionFactory.userTransaction();
          Jonathan Halliday Master

          That's almost certainly a configuration issue. Turn on the logging or trace the call in a debugger to see where it's failing. My guess would be it's not finding the correct configuration information, perhaps because you are not deploying all the right pieces or not deploying them in the right order. You could also approach the problem by starting from the working demo and changing it a bit at a time until it either looks like what you need or it breaks.

          • 2. Re: problems with UserTransactionFactory.userTransaction();
            bryan borg Newbie

            yes, it is definitely some configuration issue. I tried approaching the problem the way you suggested , but then i got stuck when generating the wsdl's and the required configuration files (using wstools.bat). These files are shipped already 'compiled' with the demo, and the ant task mereley includes them in the .wars.

            Since i'm a newbie to this technology i then decided to start with something simpler; two separate web services. I managed to deploy these succesfully (and also managed to generate the .wsdl and configuration files), however i am having this null pointer exception when trying to start the transaction from the client servlet.

            The two web servies are deployed as separate wars, and the client servlet is deployed as a separate war. Should these be deployed in one ear? (as is done with the xts-demo)

            • 3. Re: problems with UserTransactionFactory.userTransaction();
              Jonathan Halliday Master

              It's probably a classloader issue then. You need to look at the way the demo app is packaged and ensure your .war/.ear file follows the same pattern. If the classloader can't locate the relevant config files, libraries or such you'll have problems. If you want to separate out the XTS part from your app, look at the docs on configuring a standalone coordinator.

              • 4. Re: problems with UserTransactionFactory.userTransaction();
                bryan borg Newbie

                Hi again,

                I started modifying the xts-demo as you suggested and i managed to reduce it to the theater web service and the taxi web service ... that makes the whole thing more manageable.

                I tried making slight modifications to the theater and taxi web service however i got stuck when it comes to the generation of the client and server side stubs. The build script for the xts-demo does not provide any regeneration ability for the stubs. Can you suggest where to find the wstools-config.xml or point me to the appropriate reading material ?

                Many thanks

                • 5. Re: problems with UserTransactionFactory.userTransaction();
                  Andrew Dinn Master

                   


                  Can you suggest where to find the wstools-config.xml or point me to the appropriate reading material ?


                  JBoss AS 4.2 provides a tool wsconsume which will generate client and server interfaces from wsdl. You could also try using the equivalent CXF and glassfish tools.