8 Replies Latest reply on Jul 19, 2013 6:07 AM by paolo.compieta

    UserTransaction jndi issue

    freakwave10

      Hi all,


      I deployed a seam WAR project on WebSphere. The issue I am facing is in regards to the JNDI name of the userTransaction Object.
      On Websphere the JNDI name is jta/usertransaction
      Which is not the default used by seam.


      According to the https://jira.jboss.org/jira/browse/JBSEAM-4154 the  org.jboss.seam.core.init.userTransactionName attribute has been removed.


      During a async call from a POJO I always get the following exception:



      javax.naming.ConfigurationException [Root exception is javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".]
           at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:411)
           at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:388)
           at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:204)
           at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:144)
           at javax.naming.InitialContext.lookup(InitialContext.java:363)
           at org.jboss.seam.transaction.Transaction.getUserTransaction(Transaction.java:79)
           at org.jboss.seam.transaction.Transaction.createUTTransaction(Transaction.java:71)
           at org.jboss.seam.transaction.Transaction.getTransaction(Transaction.java:44)
           at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           at java.lang.reflect.Method.invoke(Method.java:618)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2211)
           at org.jboss.seam.Component.unwrap(Component.java:2237)
           at org.jboss.seam.Component.getInstance(Component.java:2004)
           at org.jboss.seam.Component.getInstance(Component.java:1967)
           at org.jboss.seam.Component.getInstance(Component.java:1961)
           at org.jboss.seam.Component.getInstance(Component.java:1934)
           at org.jboss.seam.Component.getInstance(Component.java:1929)
           at org.jboss.seam.transaction.Transaction.instance(Transaction.java:36)
           at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts(Contexts.java:331)
           at org.jboss.seam.contexts.Lifecycle.endCall(Lifecycle.java:96)
           at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.cleanup(Asynchronous.java:91)
           at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:84)
           at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
           at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
           at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
           at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
      Caused by: javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
           at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1095)
           at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:991)
           at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
           at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:384)
           ... 27 more



      how can I configure seam to lookup the userTransaction with the proper name?
      (on jboss, everything works as expected)


      Kind regards,


      Wolfgang


        • 1. Re: UserTransaction jndi issue
          freakwave10

          Ok, I did some more tracing on Jboss and Websphere,


          the problem seems to be in the asynchronous thread that is executed. From this thread, the jndi lookup fails.


          Here is the jboss trace (working)



          2009-07-22 11:51:00,837 TRACE [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.transaction.transaction
          2009-07-22 11:51:00,837 TRACE [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.transaction.transaction
          2009-07-22 11:51:00,837 TRACE [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.org.jboss.seam.transaction.transaction
          2009-07-22 11:51:00,837 TRACE [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.transaction.transaction
          2009-07-22 11:51:00,837 TRACE [org.jboss.seam.Component] done initializing: org.jboss.seam.transaction.transaction
          2009-07-22 11:51:00,837 TRACE [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postCreate.org.jboss.seam.transaction.transaction
          2009-07-22 11:51:00,838 ERROR [STDERR] 
          ------------------------------------------------------------------------
          2009-07-22 11:51:00,838 ERROR [STDERR] tibjmsTopicSubscriber SAMPLE
          2009-07-22 11:51:00,838 ERROR [STDERR] ------------------------------------------------------------------------
          2009-07-22 11:51:00,838 ERROR [STDERR] Server....................... tcp://dev-tibco01:7222
          2009-07-22 11:51:00,838 ERROR [STDERR] User......................... (null)
          2009-07-22 11:51:00,838 ERROR [STDERR] Queue........................ meAccountCreationV2.queue
          2009-07-22 11:51:00,838 ERROR [STDERR] ------------------------------------------------------------------------
          2009-07-22 11:51:00,838 ERROR [STDERR] Subscribing to topic: meAccountCreationV2.queue





          Here is the websphere trace:


          [22/07/09 11:41:03:358 CEST] 00000029 Component     2 org.jboss.seam.Component newInstance instantiating Seam component: org.jboss.seam.transaction.transaction
          [22/07/09 11:41:03:358 CEST] 00000029 Events        2 org.jboss.seam.core.Events raiseEvent Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.transaction.transaction
          [22/07/09 11:41:03:358 CEST] 00000029 Events        2 org.jboss.seam.core.Events raiseEvent Processing event:org.jboss.seam.postSetVariable.org.jboss.seam.transaction.transaction
          [22/07/09 11:41:03:358 CEST] 00000029 Component     2 org.jboss.seam.Component initialize initializing new instance of: org.jboss.seam.transaction.transaction
          [22/07/09 11:41:03:358 CEST] 00000029 Component     2 org.jboss.seam.Component initialize done initializing: org.jboss.seam.transaction.transaction
          [22/07/09 11:41:03:358 CEST] 00000029 Events        2 org.jboss.seam.core.Events raiseEvent Processing event:org.jboss.seam.postCreate.org.jboss.seam.transaction.transaction
          [22/07/09 11:41:03:358 CEST] 00000029 javaURLContex E   NMSV0310E: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. Exception stack trace: 
          javax.naming.ConfigurationException [Root exception is javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".]
               at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:411)
               at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:388)
               at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:204)
               at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:144)
               at javax.naming.InitialContext.lookup(InitialContext.java:363)
               at org.jboss.seam.transaction.Transaction.getUserTransaction(Transaction.java:79)
               at org.jbos
          



          Initially I thought it is the quartz scheduler that is used for the Asynchronous thread processing, I changed the seam.quartz.properties to contain the proper user transaction jndi lookup. But this did not change anything.


          Any ideas?


          Thanks a lot,


          Wolfgang

          • 2. Re: UserTransaction jndi issue
            freakwave10

            Ok, now I finally have some solution to this.


            Since the transaction lookup is the problem, I change the transaction strategy in Seam and disabled global managed transactions, and add manual transactions via annotations where I need them.
            Since I changed this and not have a transaction active for the JMS subscription asynchronous call, it also works on WebSphere.


            Perhaps I have to add here that this is only is a problem with POJO's. If I utilize the WebSphere EJB container, and replace my POJO with session beans, these problems do not occur.



            Wolfgang


            • 3. Re: UserTransaction jndi issue
              meneghette.meneghette.gmail.com

              Hi, in my case need to get Transaction working with Quartz at WebSphere.


              I Create a Quartz Process, when I Try do get some data from database, I get same stacktrace post previus


              ...Caused by: javax.naming.NameNotFoundException: Name comp/UserTransaction not found in context java:.


              At Jboss Works, but at Websphere is not working,


              Please I need to get this to work at websphere, Please some help,


              Thanks

              • 4. Re: UserTransaction jndi issue
                titou09

                What version of seam are you using?


                What version of WebSphere are you using?


                What do you mean by it is not working


                I have opened a PMR for this as WAS was displaying this travecack even if the exception was catched by seam and I have commit changes some time ago in Seam to deal with this... The problem is solved in the latest version of WAS and the latest version of Seam...

                • 5. Re: UserTransaction jndi issue
                  meneghette.meneghette.gmail.com

                  Hello Denis,


                  I'm using seam 2.2.0GA
                  Websphere 6.1 (I cannot change because i'm not the enviroment owner, mus be this version)


                  It not working I mean : When I use some process using quartz I'm getting this exception, when I try to do any operation like em.query ou em.merge


                  ...Caused by: javax.naming.NameNotFoundException: Name “comp/UserTransaction” not found in context “java:”.


                  Than I cannot perfome any operation at database


                  This happen only on quartz, my application works perfect


                  Thanks for you answer




                  • 6. Re: UserTransaction jndi issue
                    titou09

                    OK.
                    You should give a try to the latest version of Seam (v2.2.1) as this version includes changes in this area.


                    But I don't know if it will work with WAS v6.1 We are using WAS v7.0.0.13 here and we are using EJB3 timer as implementation of the asynchronous tasks.


                    In its time, I have opened a few PMR related to the JNDI lookups that were forbidden by WAS v7.0 in certain places or because this jndi namespace was not exposed where it should be that were causing probleme similar to what you are facing now. All were fixed in WAS v7.0.0.9 and Seam v2.2.1  but I don't know if the problem was also present in WAS v6.1


                    The APARs corresponding to the PMRs I opened at that time are PK97995 and PK98746 (both included in WAS v7.0.0.9). They resolution doesn't say that they were also present in WAS v6.1...


                    • 7. Re: UserTransaction jndi issue
                      meneghette.meneghette.gmail.com
                      Hi I installed WebSphere 7.0.0.19 and I'm using seam 2.2.2.final,

                      And I1m still getting the exception on async call using quartz (I'm not using EJB)

                      Here is the exception

                      000000bf AsynchronousE E org.jboss.seam.async.AsynchronousExceptionHandler handleException Exception thrown whilst executing asynchronous call java.lang.RuntimeException: exception invoking: getTransaction

                      Caused by: javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".]


                      Can someone help me ?
                      • 8. Re: UserTransaction jndi issue
                        paolo.compieta

                        Hi all,

                        you might be interested in these additional configurations/refactoring, which i found necessary to avoid the NMSV0310E/J2EEContext problem: see Unmanaged Threads Spring Quartz Websphere Hibernate

                         

                        Regards,

                        Paolo