2

I tried to use

 @Resource(mappedName = "jms/ConnectionFactory")
 private static ConnectionFactory connectionFactory;
 @Resource(mappedName = "jms/Queue")
 private static Queue queue;

to instantiate JMS stuff inside my application running in Glassfish (4.0).

I created these resources via the NetBeans (7.4rc1) Wizards and saw that they created a glassfish-resources.xml in /setup/ with this connector-resource. I verified per Glassfish's asadmin list-jms-resources command (and in the web-based admin page) that the resources are available.

But whenever I try to access these fields inside my application they are null.

I saw that this problem can happen when running the application in eclipse (Resources injection doesn't work when running jms examples in eclipse.) but I start my application from NetBeans (which automatically starts integrated Glassfish and brings - I thought - everything out-of-the-box).

I also saw Trouble injecting resources with Java EE 6 and Glassfish 3.1 using @Resource but cross-checked that the lookup name is already correct.

Other hints what I have to care of to get the JNDI lookup work?

Community
  • 1
  • 1
Mayoares
  • 1,234
  • 2
  • 13
  • 21

0 Answers0