I am stuck up with UserTransaction JNDI lookup (with jta/usertransaction) in WebSphere 6 from standalone non J2EE application client JVM.
Client JVM has thrown the following exception while lookup:
May 24, 2005 11:49:47 AM com.ibm.ws.naming.util.Helpers
WARNING: jndiGetObjInstNoop
Exception in thread "P=586654:O=0:CT" java.lang.ClassCastException: javax.naming.Reference
Both the WebSphere container and standalone client uses IBM JDK 1.4.2 and I have placed all necessary JAR files in the client's CLASSPATH, but still the ClassCastException resulted.
Below is the sample code of the application client:
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:2809");
Context ctx = new InitialContext(props);
javax.transaction.UserTransaction userTrans = (javax.transaction.UserTransaction) ctx.lookup("jta/usertransaction");
userTrans.begin();
Could anyone please look into this and let me know what went wrong with the lookup?
Thanks,
Pardha.
Why are you starting a transaction at the client? This is usually not a
good idea.
Thanks for your response. I ran C:\IBM\WebSphere\AppServer\bin\setupCmdLine.bat and then the client application client with the command you have suggested. But I got the another exception as folllows:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.ibm.rmi.iiop.CDROutputStream.<clinit>(CDROutputStream.java:1127)
at com.ibm.rmi.corba.ORB.<init>(ORB.java:260)
at com.ibm.rmi.iiop.ORB.<init>(ORB.java:181)
at com.ibm.CORBA.iiop.ORB.<init>(ORB.java:559)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.
java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAcces
sorImpl.java:44)
at java.lang.reflect.Constructor.newInstance(Constructor.java:315)
at java.lang.Class.newInstance3(Class.java:367)
at java.lang.Class.newInstance(Class.java:305)
at org.omg.CORBA.ORB.create_impl(ORB.java:326)
at org.omg.CORBA.ORB.init(ORB.java:367)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:82)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:174)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:97)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:73)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:386)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:285)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory
java:373)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:112)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:422)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:143)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at EjbLookup.main(EjbLookup.java:21)
Caused by: java.lang.SecurityException: java.lang.Object:java.security.NoSuchAlgorithmException
: SHA MessageDigest not available
at com.ibm.rmi.io.ObjectStreamClass._computeSerialVersionUID(ObjectStreamClass.java:114
6)
at com.ibm.rmi.io.ObjectStreamClass.init(ObjectStreamClass.java:770)
at com.ibm.rmi.io.ObjectStreamClass.lookup(ObjectStreamClass.java:322)
at com.ibm.rmi.io.ObjectStreamClass.lookup(ObjectStreamClass.java:312)
at com.ibm.rmi.util.RepositoryId.createHashString(RepositoryId.java:754)
at com.ibm.rmi.util.RepositoryId.<clinit>(RepositoryId.java:213)
... 24 more
Caused by: java.security.NoSuchAlgorithmException: SHA MessageDigest not available
at java.security.Security.getAlgClassName(Security.java:578)
at java.security.Security.getAlgClassName(Security.java:600)
at java.security.Security.getImpl(Security.java:1081)
at java.security.MessageDigest.getInstance(MessageDigest.java:135)
at com.ibm.rmi.io.ObjectStreamClass._computeSerialVersionUID(ObjectStreamClass.java:101
5)
... 29 more
I have the following entries in java.security file under %WAS_HOME%\java\jre\lib\security directory:
#
# List of providers and their preference orders (see above):
#
security.provider.1=com.ibm.crypto.provider.IBMJCE
security.provider.2=com.ibm.jsse.IBMJSSEProvider
security.provider.3=com.ibm.jsse2.IBMJSSEProvider2
security.provider.4=com.ibm.security.jgss.IBMJGSSProvider
security.provider.5=com.ibm.security.cert.IBMCertPath
#security.provider.6=com.ibm.crypto.pkcs11.provider.IBMPKCS11
I have no idea what was cauising this new exception?
Please let me know do I need to set any other enviromnment vars.
Thanks,
Pardha
WebSphere does not support the use of UserTransaction in a client
environment.
Regards,
David
I should probably be more specific - the use of UserTransaction in a
*thin* client environment is not supported. It is supported in the
client container in WAS 6 as documented in the InfoCenter:
Regards,
David
I installed WAS 6 with the examples for Message Driven Beans. I wrote the following code (similar to the one that Pardha has, running outside the appserver) and ran into the same exception:
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");
Context context = new InitialContext(props);
TopicConnectionFactory cf = (TopicConnectionFactory) context.lookup("Sample/JMS/MDB/CF");
For some unknown reason, the context seems to fail deserializing the connection factory object and only returns a reference to the object. Does anyone know what setups are required to get such an application woking (jar files, property files, environment variables, etc.)? Any help is greatly appreciated. Thanks.
Did you try looking in the WAS infocenter?
export JAVA_EXT_DIRS=$WAS_HOME/java/jre/lib/ext:$WAS_HOME/lib:$WAS_HOME/plugins:$WAS_HOME/classes
Then use it in java command line. -Djava.ext.dirs=$JAVA_EXT_DIRS