Discussions

EJB programming & troubleshooting: an odd problem with Transaction

  1. an odd problem with Transaction (5 messages)

    Hello,
    I need to make transational some EJB invocations.
    I'm using Weblogic 5.1.

    UserTransaction tx = (UserTransaction)ejb.getContext().lookup("javax.transaction.UserTransaction");

    tx.begin();

    What I get when I try to instantiate tx object is a
    java.lang.ClassCastException:
    weblogic.jts.internal.CurrentImpl

    I tried to investigate on tx'class and it's indeed a
    weblogic.jts.internal.CurrentImpl

    How can it be that this code works in some parts of my code and here doesn't work?? it depends on the content of Context
     in that moment??
    Any clue will be highly appreciated!
    Thanks
    Francesco

    Threaded Messages (5)

  2. an odd problem with Transaction[ Go to top ]

    Why don't you use context.getUserTransaction(), where context is the Session- or EntityContext of your EJB?
  3. an odd problem with Transaction[ Go to top ]

    I'm afraid I can only use JNDI If I want to create an UserTransaction on the client side.....please correct me If I'm wrong.
  4. Aarrgh!!! I found it out!
    I have to import
    import javax.transaction.*;

    a NOT this!!
    import javax.jts.*;

    importing the latter will cause the ClassCastException
    problem.

    Bye
    Francesco
  5. Did u get the solution?? If not contact me at chandu at realprompt dot com


    chandu
  6. an odd problem with Transaction[ Go to top ]

    If you are starting the transaction from a JSP or servlet, use:

    Context initCtx = new InitialContext();

    UserTransaction tx = (UserTransaction) initCtx.lookup("java:comp/UserTransaction");