• Post Reply Bookmark Topic Watch Topic
  • New Topic

Container injecting JMS resources to EJB dependencies

 
Janne Mattila
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using EJB (3.1), container should manage amongst others the JMS resources. Bean developer either configures @Resource annotations to the bean, or resource-refs into ejb-jar.xml.

questions:

1. What if the @Resource annotations are not in the EJB itself, but in some utility class, injected into EJB using CDI (or even deeper in injection path EJB <- util1 <- ... <- util n)? For example my EJB:




does this work, and is it standard and portable? (it does work on Glassfish v3) Is this defined in the specs somewhere?

2. What's the behavior if bean developer does not use @Resource-annotations or resource-refs, and instead tries to access JMS straight from code (tries to look up connectionFactory directly from JNDI, for example)? What does specification say (is result "undefined"), and if its undefined, what happens in practise?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Janne,
I believe injection doesn't work for POJOs in EJB 3.1. It definitely isn't portable in EJB 3.

Looking up the JMS resources from the JNDI is perfectly fine. Since an EJB calls the POJO it is operating under the app server's context.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!