Are you runing this piece of code in the server container or in a standalone Web service client? Looks like you are running in the client. You can't access the server context (resources) in the standalone client.

-Jack

2009/3/3 David Jencks <david_jencks@yahoo.com>

On Mar 2, 2009, at 7:30 AM, Kaupo wrote:


I have configured a datasource in my application, but i have problems
accessing it when when I connect to my application through a webservice and
try to use it!
I get the following error:
"java.lang.NullPointerException: You have accessed the java:comp jndi
context on a thread that has not initialized it"

The code that is use:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MyDataSource");
con = ds.getConnection();

This is reasonable code in a javaee component inside the server.  Could you provide a complete stack trace?



I read here  http://cwiki.apache.org/GMOxDOC21/jndi.html
http://cwiki.apache.org/GMOxDOC21/jndi.html  that one can access the
resources by using the "jca:{groupId}/{artifactId}/{j2eeType}/{name}"
notation, but I'm having a hard time figuring out the j2eeType part.

How do I know what to put instead of j2eeType?

If you look in var/log/geronimo.log the jndi locations are logged as the comonents start up.  I prefer to look at these rather than try to remember which j2eeType is in use.

thanks
david jencks



--
View this message in context: http://www.nabble.com/jndi-datasource-access-problem-tp22290284s134p22290284.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.