users@glassfish.java.net

Re: glassfish and tomcat when using appserv-rt.jar

From: <glassfish_at_javadesktop.org>
Date: Thu, 03 Jan 2008 03:33:28 PST

Thanks for your reply.

My problem is that the same application is trying to get a datasource from tomcat and lookup an EJB hosted on glassfish.

Since the link and other articeles I read, instruct to add the appserv-rt.jar to the client classpath and since my application need to use both Contexts (datasource for tomcat and EJB for glassfhish), I've tried to delete the jndi.properties file from appserv-rt.jar . When tomcat tried to lookup the datasource, I got the below Exception:

[u]My code:[/u]
Context ctx = new InitialContext();
String env = "java:comp/env/";
myDs = (DataSource) ctx.lookup(env + getPluginProperty("myDs"));

[u]The Exception:[/u]
javax.naming.NameNotFoundException: PWC4216: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:791)
at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at net.db.DBPlugIn.init(DBPlugIn.java:224)

I debuged and found out that javax.naming.Context!defaultInitCtx are different:
with appserv-rt.jar in classpath - org.apache.naming.NamingContext
without appserv-rt.jar in classpath - org.apache.naming.SelectorContext

I got the same Exception also when I used appserv-rt.jar with the jndi.properties (I did not delete it from the jar)

Please advice

Thanks,
Ron
[Message sent by forum member 'rong999' (rong999)]

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