aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes InjectionException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "InjectionException" Watch "InjectionException" New topic
Author

InjectionException

vinay kumar
Ranch Hand

Joined: Sep 23, 2006
Posts: 31
Hi,

I am using Glassfish 2.1 app server. I set up a JDBC Resource with the name 'jdbc/myDB'.

And I used @Resource annotation to inject the resource in my ejb (ejb3) as below:



I didn't mention anything in deployment descriptor as I am using ejb3 with annotations.

Now, when I access this ejb from the client, I am getting the following error:

"com.sun.enterprise.InjectionException: Exception attempting to inject Res-Ref-Env-Property: jdbc/myDB@javax.sql.DataSource@ resolved as: jndi: jdbc/myDB@res principal: null@mail: null
No Runtime properties
Database Vendor : null"



Can you please tell me where I am going wrong.

Thanks
Vinay
Marcos Serrano
Ranch Hand

Joined: Jul 13, 2006
Posts: 46
I think it's missing the "mappedName". I got a derby connection with jboss and works fine.

"java:jdbc/DerbyDS" is defined in jboss



toutes les jours
vinay kumar
Ranch Hand

Joined: Sep 23, 2006
Posts: 31
Thanks Marcos for reply. But I still have get the following error

com.sun.enterprise.InjectionException: Exception attempting to inject Res-Ref-Env-Property: jdbc/vinayDB@javax.sql.DataSource@ resolved as: jndi: java:jdbc/vinayDB@res principal: null@mail: null

when I use



I created the JDBCResource with name "jdbc/vinayDB". I couldn't figure it out where Im going wrong.

thanks
vinay
Sai Surya
Ranch Hand

Joined: Feb 08, 2006
Posts: 457

Is your client running in the same environment to make DI work? If you are calling client from outside
you can't use DI and you need to use JNDI look up to get reference to JDBC resource. If you want to
use DI from client try running client in ACC.

Hope this helps.


Sai Surya, SCJP 5.0, SCWCD 5.0, IBM 833 834
http://sai-surya-talk.blogspot.com, I believe in Murphy's law.
vinay kumar
Ranch Hand

Joined: Sep 23, 2006
Posts: 31
Yes. I am running the client (a web project ) and ejb (ejb project) on the same Glassfish server. I am using eclipse and configured the projects correctly. I am able to access the Session bean created on ejb project from the client project.

I couldn't figure it out still. please help.
Ramesh Pentakota
Greenhorn

Joined: Apr 26, 2009
Posts: 1
Vinay,

I was able to get connection from Datasource using DI in EJB as shown below.

@Resource(name="jdbc/rameshDB") private javax.sql.DataSource myDB;

May be connection pool configuration has to be reviewed.


Ramesh
<SCJP1.5><SCDJWS><SCBCD5.0>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InjectionException