users@glassfish.java.net

InitialContext Look-up Issue

From: <forums_at_java.net>
Date: Tue, 7 Jun 2011 09:43:27 -0500 (CDT)

Good morning!

I did some searching, but I wasn't able to find a satisfactory solution.

The problem I'm running into is that I'm developing a web application.
Unfortunately, our test environment (Glassfish) is different from our
production environment. On the Glassfish 3.1 app server, the following code:

Context initContext = new InitialContext();     Context envContext  =
(Context)initContext.lookup("java:/comp/env");     DataSource ds =
(DataSource)envContext.lookup("jdbc/TpsSource");
Is giving me the following error:

[#|2011-06-06T16:16:40.214-0400|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=104;_ThreadName=Thread-1;|Get
Client Caught exception: Lookup failed for 'java:/comp/env' in
SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
java.naming.factory.url.pkgs=com.sun.enterprise.naming}<br>|#]
Now, I know for Glassfish, the environment subcontext is unnecessary.
However, I cannot remove the look-up of "java:/comp/env" from the code. Is
there a way I can configure the Glassfish application server to NOT bomb on
this piece of code?

Thanks in advance for any help!


--
[Message sent by forum member 'Kanonen80']
View Post: http://forums.java.net/node/809998