• Post Reply Bookmark Topic Watch Topic
  • New Topic

Injecting JMSContext result in NullpointerException  RSS feed

 
Yue Shen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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!
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!