aspose file tools*
The moose likes Web Services and the fly likes RestEasy+EJB in JBoss 7, here @Inject throws Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "RestEasy+EJB in JBoss 7, here @Inject throws Null Pointer Exception" Watch "RestEasy+EJB in JBoss 7, here @Inject throws Null Pointer Exception" New topic
Author

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

Sachin Pachari
Ranch Hand

Joined: Jan 16, 2012
Posts: 56

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
timo erler
Greenhorn

Joined: Dec 04, 2012
Posts: 2
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

Joined: Dec 04, 2012
Posts: 2
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 ;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RestEasy+EJB in JBoss 7, here @Inject throws Null Pointer Exception