How to write a client..?

Discussions

EJB programming & troubleshooting: How to write a client..?

  1. How to write a client..? (5 messages)

    Hi Guys.. I'm trying to write a client for a bean which is deployed as transaction attribute as MANDATORY. A normal client fails saying TransactionRequiredException. Can some one tell me how to start/create a transaction at the client ? or u can some other way of writing a client for MANDATORY.
    Any help is appreciated.
    Thanks in advance.
    Anil.

    Threaded Messages (5)

  2. How to write a client..?[ Go to top ]

    You need to start a UserTransaction on your client. If you're connecting via RMI/IIOP this may not be possible, as not all (iPlanet for instance) app servers allow you start a transaction remotely.

    For example (from the iPlanet docs):-

    InitialContext ctx = null;
    String dsName1 = "jdbc/GlobalSampleDS";
    DataSource ds1 = null;

    try
    {
       ctx = new InitialContext();
       ds1 = (DataSource)ctx.lookup(dsName1);

       UserTransaction tx = ejbContext.getUserTransaction();

       tx.begin();

       Connection conn1 = ds1.getConnection();

       // use conn1 to do some database work -- note that conn1.commit(),
       // conn1.rollback() and conn1.setAutoCommit() can not used here

       tx.commit();

    } catch(Exception e) {
       e.printStackTrace(System.out);
    }
  3. How to write a client..?[ Go to top ]

    Hi Many Thanks for the response. But I'm using WebLogic 6.0/6.1 and in the code which u wrote there is one ejbContext variable/instance is there could u explain me from where it has come ? i'm not able to understand.

    Thanks in advance.
    Anil.
  4. How to write a client..?[ Go to top ]

    I bet Richard is using the ejbContext that is available for you to store when the container invokes the setEntityContext(EntityContext ctx).

    Regs.
    Martin
  5. How to write a client..?[ Go to top ]

    Check the weblogic documentation, I found this in 5 minutes :-)

    http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1081136

    Cheers,
    Rick
  6. How to write a client..?[ Go to top ]

    do you still need help regarding that ...