This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@Resource injection not working for DataSource

 
pulkit mehra
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic