aspose file tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes @Resource injection not working for DataSource Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Reply Bookmark "@Resource injection not working for DataSource" Watch "@Resource injection not working for DataSource" New topic
Author

@Resource injection not working for DataSource

pulkit mehra
Greenhorn

Joined: Jun 05, 2008
Posts: 12
Hi Ranchers,

I am facing some problem in getting datasource from JNDI using @Resource annotation.
My server is JBoss5.1 and EJB 3.0.
My DS file

My Persistence.xml

StatelessBean

Web Client(local in Server EAR)

Problem Faced:
1)Not able to get statelessbean instance as resource injection getting failed.I have checked JMX console's JNDI view.
I am able to locate titanDatasource in Global section as well as in stateless bean ENC(linking global JNDI titanDatasource)
ServerError is :

2)I am confused between @Resource attribute name and mappedName My understanding is MappedName reference Global JNDI attributes where as name reference ENC attributes;

Please helpe me!!

pulkit mehra
Greenhorn

Joined: Jun 05, 2008
Posts: 12
Hi Friends ,

My server unexpectedly start working in above said scenario .Cant rely on open source servers but here what i have learned :

1)DS can be binded to java namespace or into Global JNDI section using <use-java-context> in DS file.
2)Always use DI names as per binding:
If used <use-java-context> true then mappedName = 'java:/titanDatasource'
If used <use-java-context> false then mappedName = 'titanDatasource'

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: @Resource injection not working for DataSource
 
Similar Threads
Exception got in deployment of EJB3 .ear
Problem with look up JNDI on JBOSS
Name Not Bound Exception
About Pure java driver with JBOSS
org. postgresql. util. PSQLException: ERROR: relation does not exist