• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Container injecting JMS resources to EJB dependencies

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 42003
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic