users@grizzly.java.net

setting up JNDI datasource in embedded Grizzly

From: Philippe Marschall <kustos_at_gmx.net>
Date: Sun, 11 Oct 2009 16:26:22 +0200

Hi

I have an existing servlet application that uses JNDI to look up a
DataSource. I'm trying to run this application in an embedded Grizzly
but I failed to register the DataSource.

The servlet code to look up the DataSource. is like this, it's working
in Tomcat.

InitialContext context = new InitialContext();
DataSource source = (DataSource)
context.lookup("java:/comp/env/jdbc/com.acme");

My code to set up the DataSource. look like this:

DataSource pool = ....;
Context ctx = new InitialContext();
ctx.bind("jdbc/jdbc/com.acme", pool);

However this throws an exception because java.naming.factory.initial is
not set.

Cheers
Philippe