Hello,
when you use the name attribute in the @Resource annotation, you have
to map your name (jdbc/ucs) to real JNDI resource in the
WEB-INF/sun-web.xml.
Create the file if it doesn't exist and put these lines into it:
<resource-ref>
<res-ref-name>jdbc/ucs</res-ref-name>
<jndi-name>jdbc/Connection/configured/in/GlassFish</jndi-name>
</resource-ref>
This is prefered method. The other way is to use mappedName attribute
instead of name i which you can directly write your real JNDI resource
name. This is not so cool solution because your source codes have
wired these configuration options and in case of change you have to
recompile... This also brakes the option to deploy the same
application twice using different context path (for testing purpose
i.e.) because they will share the same data source.
Have a lot of fun!
PETR
On 8/21/07, glassfish_at_javadesktop.org <glassfish_at_javadesktop.org> wrote:
> hello
>
> i'm trying to inject a jdbc resource in a managed bean's datasource variable:
> @Resource (name = "jdbc/ucs", type = javax.sql.DataSource.class, authenticationType = Resource.AuthenticationType.APPLICATION, shareable = true)
> DataSource ds;
>
> and getting
> com.sun.enterprise.InjectionException: Exception attempting to inject Res-Ref-Env-Property: jdbc/ucs_at_javax.sql.DataSource@ resolved as: jndi: jdbc/ucs_at_res principal: null_at_mail: null
> No Runtime properties
> Database Vendor : null
> Create Tables at Deploy : false
> Delete Tables at Undeploy : false into class ser.MBean
>
> error, while ds = (DataSource) new InitialContext().lookup("jdbc/ucs");
> work just fine.
>
> where is the bug?
> [Message sent by forum member 'dimm' (dimm)]
>
> http://forums.java.net/jive/thread.jspa?messageID=231750
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>