users@glassfish.java.net

Re: RE: JNDI lookup, dependency injection, datasource

From: <glassfish_at_javadesktop.org>
Date: Tue, 15 Jun 2010 07:55:36 PDT

Jagadish, Sigal: Thanks for responding. I've been trying to get a DataSource resource to import into my JSR-196 SAM via resource injection or JNDI lookup, but I can't get it to work in either case.

I put some JNDI lookup code into a class I have annotated with @ManagedBean:

Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup( "java:comp/env/jdbc/myDB" );

This code returns a type of com.sun.gjc.spi.jdbc40.DataSource40. However the type defined in the <data-source> element of web.xml is:

<class-name>com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource</class-name>


The MySql connector jar is deployed with my application (in the .war) via NetBeans. I'd really like to understand what's happening and how to make information in web.xml available to the entire application.

Best Regards,
Andrew
[Message sent by forum member 'andrewlaughlin']

http://forums.java.net/jive/thread.jspa?messageID=474349