Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JNDI Access from Sun JRE on Websphere 6

424 views
Skip to first unread message

thomas....@avignon.inra.fr

unread,
Sep 12, 2006, 11:07:34 AM9/12/06
to
Hi!

I'm trying to access to jndi resources on a Websphere 6 server from a tomcat 5.5 app running under Sun JRE in order to send JMS message.

This is my main code :

Hashtable<String, String> h = new Hashtable<String, String>();
h.put(Context.SECURITY_PRINCIPAL, "guest");
h.put(Context.SECURITY_CREDENTIALS, "guest");
h.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
h.put(Context.PROVIDER_URL, "iiop://localhost:2809");
Context jndi = null;
QueueConnectionFactory conFabrique = null;
try {
jndi = new InitialContext(h);
if (jndi != null) {
System.out.println("jndi = " + jndi);

Hashtable hash = jndi.getEnvironment();
Enumeration<String> keys = hash.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
System.out.println(key + " : " + hash.get(key));
}

conFabrique = (QueueConnectionFactory) jndi
lookup(connectionFactoryName);
queue = (Queue) jndi.lookup(queueName);
} else {
System.out.println("JNDI non initialisé");
}
} catch (NamingException e) {
e.printStackTrace();
}

And this is the exception :

javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.ClassCastException: com.sun.corba.se.impl.orb.ORBImpl]
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:318)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:392)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:117)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:712)
at com.ibm.ws.naming.util.WsnInitCtx.getEnvironment(WsnInitCtx.java:677)
at javax.naming.InitialContext.getEnvironment(InitialContext.java:484)
at fr.inra.p2i.jms.Sender.init(Sender.java:151)
at fr.inra.p2i.jms.Sender.<init>(Sender.java:116)
at fr.inra.p2i.jms.Main.main(Main.java:9)
Caused by: java.lang.ClassCastException: com.sun.corba.se.impl.orb.ORBImpl
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:86)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:179)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:83)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:59)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:102)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:309)
.. 8 more

This exception is thrown at jndi.getEnvironment(), or when I discard this line, at jndi.lookup.

Of course I put in CLASSPATH of Sun's JRE all jar files in IBM_JDK_HOME/jre/lib and IBM_JDK_HOME/jre/lib/ext

If I run my code with IBM JRE, it runs without any error!!! How can I make it run on Sun's JRE?
I think maybe I can add an h.put(...) to say how to get some class but I really don't know what...
Please help me!!

Thanks!!


Paul Ilechko

unread,
Sep 12, 2006, 12:51:33 PM9/12/06
to
thomas....@avignon.inra.fr wrote:
> Hi!
>
> I'm trying to access to jndi resources on a Websphere 6 server from a
> tomcat 5.5 app running under Sun JRE in order to send JMS message.

> If I run my code with IBM JRE, it runs without any error!!! How can I


> make it run on Sun's JRE?

http://www-1.ibm.com/support/docview.wss?uid=swg24012804

thomas....@avignon.inra.fr

unread,
Sep 13, 2006, 7:33:28 AM9/13/06
to
Yes!

Exactly what I want!

Thanks!

It works pretty good now!
Still just a security problem but I will try to resolve it.

Thanks again

Regards

Tom.

Samuel Lima

unread,
Oct 4, 2006, 11:55:52 AM10/4/06
to
What about accessing an EJB on WAS 6 from Sun JRE 1.5 (especificaly from Tomcat 5.5) ?

I tried the code below but got exception on "home.create()"

Put the j2ee.jar in the "\Tomcat 5.5\common\lib" directory.

Tried some sites but didn´t work.

Any hint? Has someone tried it successfully?

Thanks.


Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://li09:2809");
InitialContext ctx = new InitialContext(env);
Object obj = ctx.lookup("cell/nodes/li09Node01/servers/server1/ejb/com/porto/informatica/sasi/eai/ChamadoTecnicoSmartHome");
ChamadoTecnicoSmartHome home = (ChamadoTecnicoSmartHome)PortableRemoteObject.narrow(obj, ChamadoTecnicoSmartHome.class);
ChamadoTecnicoSmart remote = home.create();

Oct 4, 2006 12:31:24 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Lookup threw exception
java.lang.ClassCastException: com.sun.corba.se.impl.corba.CORBAObjectImpl
at com.porto.informatica.sasi.eai._ChamadoTecnicoSmartHome_Stub.create(_ChamadoTecnicoSmartHome_Stub.java:213)
at com.porto.infra.lookup.servlet.Lookup.processa(Lookup.java:63)
at com.porto.infra.lookup.servlet.Lookup.doGet(Lookup.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

Paul Ilechko

unread,
Oct 4, 2006, 12:21:06 PM10/4/06
to
Samuel Lima wrote:
> What about accessing an EJB on WAS 6 from Sun JRE 1.5 (especificaly from Tomcat 5.5) ?
>
> I tried the code below but got exception on "home.create()"
>
> Put the j2ee.jar in the "\Tomcat 5.5\common\lib" directory.
>
> Tried some sites but didn´t work.
>
> Any hint? Has someone tried it successfully?
>
> Thanks.
>

Read up on "pluggable application clients" in the WAS infocenter.

Samuel Lima

unread,
Oct 4, 2006, 6:00:38 PM10/4/06
to
> Read up on "pluggable application clients" in the WAS
> infocenter.

Thanks again Paul,

I did it but when I saw it takes about 36mb to generate a "thin" client for Sun JRE I decided to dig a litle deeper.

I made it copying the jars (below in this post) from WAS 6 to the lib folder of the web project.

Just couldn´t use the com.ibm.websphere.naming.WsnInitialContextFactory, had to use com.sun.jndi.cosnaming.CNCtxFactory.

It also only worked using fully qualified name for lookup: "cell/nodes/li09Node01/servers/server1/ejb/com/porto/informatica/model/CadastroFuncionarioModelHome" instead of just "ejb/com/porto/informatica/model/CadastroFuncionarioModelHome"

I also worked with falt tolerance on cluster throught corbaloc

Started two servers in cluster (9812, 9816) then stopped the first, tried the lookup, then started the first and stopped the next and everything worked well.

Next step I´m going to try Tomcat 4.1.3 with jre 1.4.


Below the code:

Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
env.put("java.naming.provider.url", "corbaloc::li38:9812,:li38:9816");
InitialContext initContext = new InitialContext(env);
Object obj = initContext.lookup("cell/clusters/clusterMdlCorp01/ejb/com/porto/informatica/model/CadastroFuncionarioModelHome");
CadastroFuncionarioModelHome home = (CadastroFuncionarioModelHome)PortableRemoteObject.narrow(obj, CadastroFuncionarioModelHome.class);
CadastroFuncionarioModel remote = home.create();
CadastroFuncionariosVO func = remote.obterFuncionario(new Integer(603151), new Short("1"), "F");


WAS6 jars:
-----------
antlr.jar
appprofile.jar
ecutils.jar
ejbcontainer.jar
ejbportable.jar
ivjejb35.jar
namingclient.jar
pm.jar
pmimpl.jar
ras.jar
rsadaptercci.jar
rsaexternal.jar
runtime.jar
runtimefw.jar
standard.jar
utils.jar
vaprt.jar
wsexception.jar
j2ee.jar (had to remove javax.servlet package conflicting with tomcat jars)

third part jars:
----------------
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
log4j-1.2.11.jar

Randy Schnier

unread,
Oct 5, 2006, 10:26:11 AM10/5/06
to
Just be aware that when you perform this kind of surgery yourself,
you're on your own. The only supported configuration is the thin client.

raok...@yahoo.com

unread,
Aug 27, 2008, 5:02:39 PM8/27/08
to
Hi,

I tried running stand alone JMS Client sending a jms message to a topic on Websphere 6.0 node. I ran into the following issue.

javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.ClassCastException: com.sun.corba.se.impl.orb.ORBImpl]
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:318)


Then I installed IBM Client for JMS on J2SE with IBM WebSphere Application Server as mentioned in http://www-01.ibm.com/support/docview.wss?uid=swg24012804. I used the option jms_jndi_ibm.

Now when I run my application, I get the following error. Please help me on this. I attached the custom.bat, my source code. This works fine if it was run inside WAS.

java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:195)
at com.ibm.rmi.iiop.CDROutputStream. (CDROutputStream.java:1235)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at com.ibm.rmi.corba.ORB. (ORB.java:353)
at com.ibm.rmi.iiop.ORB. (ORB.java:199)
at com.ibm.CORBA.iiop.ORB. (ORB.java:667)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1243)
at org.omg.CORBA.ORB.create_impl(ORB.java:322)
at org.omg.CORBA.ORB.init(ORB.java:363)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:85)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:174)
at com.ibm.ejs.oa.EJSClientORBImpl. (EJSClientORBImpl.java:97)
at com.ibm.ejs.oa.EJSClientORBImpl. (EJSClientORBImpl.java:73)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:386)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:305)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:383)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:113)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:428)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:144)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at ServiceLocator.getConnectionFactory(ServiceLocator.java:284)
at TestTopicSender.send(TestTopicSender.java:29)
at TestTopicSender.main(TestTopicSender.java:13)
Caused by: java.lang.SecurityException: java.lang.Object:java.security.NoSuchAlgorithmException: SHA MessageDigest not availa
at com.ibm.rmi.io.ObjectStreamClass._computeSerialVersionUID(ObjectStreamClass.java:1193)
at com.ibm.rmi.io.ObjectStreamClass.init(ObjectStreamClass.java:812)
at com.ibm.rmi.io.ObjectStreamClass.lookup(ObjectStreamClass.java:364)
at com.ibm.rmi.io.ObjectStreamClass.lookup(ObjectStreamClass.java:354)
at com.ibm.rmi.util.RepositoryId.createHashString(RepositoryId.java:757)
at com.ibm.rmi.util.RepositoryId.(RepositoryId.java:287)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
... 24 more
Caused by: java.security.NoSuchAlgorithmException: SHA MessageDigest not available
at sun.security.jca.GetInstance.getInstance(GetInstance.java:158)
at java.security.Security.getImpl(Security.java:691)
at java.security.MessageDigest.getInstance(MessageDigest.java:145)

0 new messages