This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
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://aspose.com/file-tools
 
subject: @Resource injection not working for DataSource