users@glassfish.java.net

Re: JNDI lookup, dependency injection, datasource

From: <glassfish_at_javadesktop.org>
Date: Mon, 14 Jun 2010 23:29:13 PDT

You can refer the tech tip :
http://blogs.sun.com/enterprisetechtips/entry/datasource_resource_definition_in_java
and the sample
http://blogs.sun.com/enterprisetechtips/resource/DSD.zip
has web.xml, ejb-jar.xml with datasource-definition.

If you are injecting the resource, it should be on a Java EE component eg: Servlet/EJB/AppClient

Snippet from the tech-tip :

"Note that the sample application does a lookup to get access to a resource. However, it is also possible to inject the datasource as follows :

   @Stateless
   public class HelloEJB implements Hello {

     @Resource(lookup = "java:app/env/HelloEJB_DataSource")
     private DataSource app;
   ...
   ...
   }
"
[Message sent by forum member 'jr158900']

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