File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InjectionException

 
vinay kumar
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's missing the "mappedName". I got a derby connection with jboss and works fine.

"java:jdbc/DerbyDS" is defined in jboss

 
vinay kumar
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 463
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vinay kumar
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic