|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
setting up JNDI datasource in embedded GrizzlyHi
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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: setting up JNDI datasource in embedded GrizzlyHi Philippe,
we ship Grizzly without any embedded JNDI provider. But you can download one yourself. For example MirrorJNDI [1], which is opensource and should be easy to use (just include its jar to the application classpath) Additionally you'll need to explicitly set naming factory like: java - Djava .naming .factory.initial=com.smardec.jndi.mirror.MirrorInitialCtxFactory ..... or in code like: Hashtable environment = new Hashtable(); environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.smardec.jndi.mirror.MirrorInitialCtxFactory"); Context ctx = new InitialContext(environment); Hope this will help. WBR, Alexey. [1] http://www.smardec.com/products/jndi.html On Oct 11, 2009, at 16:26 , Philippe Marschall wrote: > 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 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: setting up JNDI datasource in embedded GrizzlyOleksiy Stashok wrote: > Hi Philippe, > > we ship Grizzly without any embedded JNDI provider. > But you can download one yourself. For example MirrorJNDI [1], which is > opensource and should be easy to use (just include its jar to the > application classpath) > > Additionally you'll need to explicitly set naming factory like: > java > -Djava.naming.factory.initial=com.smardec.jndi.mirror.MirrorInitialCtxFactory > ..... > > or in code like: > > Hashtable environment = new Hashtable(); > environment.put(Context.INITIAL_CONTEXT_FACTORY, > "com.smardec.jndi.mirror.MirrorInitialCtxFactory"); > > Context ctx = new InitialContext(environment); > > Hope this will help. I finally got it working with SimpleJNDI. Cheers Philippe --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |