• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Injecting JMSContext result in NullpointerException

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys

I am currently using glassfish 4.1 and JMS 2.0 for a project. I tried to inject JMSContext into a Servlet but it always returns null for context.



I even tried to specify the connection factory directly



I checked the Glassfish console and the above connection factory was created. Am I missing something?

Thanks!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a guess, but have you tried @Resource instead of @Inject? Some things, like EJBContext, SessionContext, TimerService and DataSource, but also a lot of JMS stuff, should not be injected using @Inject but using @Resource instead.

I'm also guessing that JMSConnectionFactory does not need the additional @Inject or @Resource similarly to @PersistenceContext, and that the other annotation is actually causing the failed injection.
 
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic