3 Replies Latest reply on Oct 29, 2008 12:52 AM by Vicky Kak

    Exception when using UserTransaction using JNDI lookup

    Asim Hafeez Newbie

      Hi,

      I am using JTA.jar for transaction in JBOSS 4.2 Server. When i perform the JNDI lookup using

       static public UserTransaction getUserTransaction()
       {
       UserTransaction utx = (UserTransaction)lookup("java:comp/UserTransaction"); /// getting exception at this point
      
       return utx;
       }
      
       static public Object lookup(final String name)
       {
       Context ctx = getInitialContext();
      
       Object result = null;
      
       try
       {
       result = ctx.lookup(name);
       }
       catch (NamingException ex)
       {
       throw new DAORuntimeException(ex);
       }
      
       return result;
       }
      
      


      i get classcastException as follows: The stack trace is below:

      09:32:31,289 ERROR [STDERR] java.lang.ClassCastException: org.jboss.tm.usertx.client.ServerVMClientUserTransaction cannot be cast to javax.transaction.UserTransaction
      09:32:31,289 ERROR [STDERR] at net.ncslph.dao.generic.MovieUtil.getUserTransaction(MovieUtil.java:282)
      09:32:31,289 ERROR [STDERR] at net.ncslph.dao.test.MovieDemo.doGet(MovieDemo.java:52)
      09:32:31,289 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      09:32:31,289 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      09:32:31,289 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      09:32:31,289 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      09:32:31,289 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      09:32:31,289 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      09:32:31,289 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      09:32:31,289 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      09:32:31,289 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      09:32:31,289 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      09:32:31,289 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
      


      Could anybody please help me with this issue ??