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.


2009/3/3 David Jencks <>

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  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.

david jencks

View this message in context:
Sent from the Apache Geronimo - Users mailing list archive at