• 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
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

RestEasy+EJB in JBoss 7, here @Inject throws Null Pointer Exception

 
Ranch Hand
Posts: 56
Netbeans IDE Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,

i am new to this whole web service, i am stuck with this JAXRS(RestEasy) project where i have to integrate my EJB with the Service and i am not able to @Inject or @EJB, everytime i try to inject, i get a Null Pointer Exeption, i have been Searching in google to solve this issue,

i have tried all the possible solutions. like adding @Stateless, adding Beans.xml to my META-INF and also configuring RestEasy CDI Injector Factory in my Web.xml

But no use, i am using JBoss AS 7.0, i keep on getting null pointer, is it even possible to inject any object into my (JAX-RS) Web Services ?? Someone please help me, i have been stuck in this point for more than a week. Someone Please Explain me clearly about this.

Any Kind of help is welcome.

Thanks & Regards,
Sachin
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe the following works for you

web.xml


MyApplication.java


MyResource.java is a RootResource which injetcs a Singleton-Bean containing an EntityManager.




This works for me as long as i do not work with subclasses



MySubResource injects the Singleton-Bean. Now I get the NullpointerException again.

Anyone an idea?
 
timo erler
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i solved the problem with subresources...

my resource is a bean
my subresource is a bean

so is use the following code to get my subresource-bean



all in all it was an stupid mistake, because beans are beans and managed by container ;)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic