users@glassfish.java.net

Web Service Client which uses Transaction

From: <glassfish_at_javadesktop.org>
Date: Fri, 17 Jul 2009 06:58:54 PDT

Hello!

I wrote a web service standalone client that uses a web service which requires a transaction. The web service is deployed on glassfih v2.

Here is an excerpt of the client's code:
--------------------------------------------------------------

Properties p = new Properties();
             p.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
             p.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
             p.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
             p.put("org.omg.CORBA.ORBInitialHost", "localhost");
             p.put("org.omg.CORBA.ORBInitialPort", "3700");

             InitialContext ctx = new InitialContext(p);
             System.out.println(ctx);
             
             UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");

             utx.begin(); // ---> error ! (see below)

             java.lang.String result = port.callWebService(param1, param2, param3);

             utx.commit();

--------------------------------------------------------------------

This code causes the following exception:

----------------------------------------------------------------------------------------

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.sun.enterprise.distributedtx.J2EETransactionManagerImpl
        at com.sun.enterprise.distributedtx.UserTransactionImpl.init(UserTransactionImpl.java:119)
        at com.sun.enterprise.distributedtx.UserTransactionImpl.<init>(UserTransactionImpl.java:101)
        at com.sun.enterprise.distributedtx.UserTransactionImpl.<init>(UserTransactionImpl.java:92)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:194)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)

---------------------------------------------------------------------

The class com.sun.enterprise.distributedtx.J2EETransactionManagerImpl ist part of the appser-rt.jar. I have already inlcuded this jar but nevertheless I always get this error.

I hope someone could help me!

Thanks in advance!

josh57
[Message sent by forum member 'josh57' (josh57)]

http://forums.java.net/jive/thread.jspa?messageID=356252