users@glassfish.java.net

RE: JDBC resource via JNDI

From: Jason Lee <lee_at_iecokc.com>
Date: Thu, 8 Feb 2007 15:13:14 -0600

We inject DataSources like this:

@Resource(mappedName="jdbc/Foo")
protected DataSource dataSource;

We've started doing more property (verses field) injection, but you
should get the idea...

-----
Jason Lee, SCJP
Programmer/Analyst
http://www.iec-okc.com
 

> -----Original Message-----
> From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
> Sent: Thursday, February 08, 2007 2:36 PM
> To: users_at_glassfish.dev.java.net
> Subject: JDBC resource via JNDI
>
> Hi,
>
> I have an application packed as an EAR file with two web
> modules and an EJB module,
>
> One of my application is Eclipse's Birt Report viewer, which
> works just fine!
> one of its features is to make all databases operations by
> retrieving a JDBC object via JNDI, thus eliminating the needs
> to put credentials in the report.
>
> In the JNDO url I tried to specify something like:
> java:comp/env/jdbc/edm where 'edm' is my jdbc defined
> resource, but it doesnt work,
>
>
> I tried to add in 'sun-web.xml' a resource reference as follows:
> <resource-ref>
> <res-ref-name>jdbc/edm</res-ref-name>
> <jndi-name>jdbc/edm</jndi-name>
> </resource-ref>
>
>
> but in deployment time, I get the following error:
> ---------------
> at
> com.sun.enterprise.management.deploy.DeployThread.run(DeployTh
> read.java:210)
> Caused by: java.lang.IllegalArgumentException: This web app
> [Eclipse BIRT Report Viewer] has no resource reference by the
> name of [jdbc/edm]
>
> atcom.sun.enterprise.deployment.WebBundleDescriptor.getResourc
> eReferenceByName(WebBundleDescriptor.java:622)
> ----------
>
>
> Any suggestions?
>
> Thanks,
>
>
> Asaf.
> [Message sent by forum member 'trouby' (trouby)]
>
> http://forums.java.net/jive/thread.jspa?messageID=202713
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>