This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes EntityManager is not loaded in Axis2 WebService Skeleton Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "EntityManager is not loaded in Axis2 WebService Skeleton Class" Watch "EntityManager is not loaded in Axis2 WebService Skeleton Class" New topic

EntityManager is not loaded in Axis2 WebService Skeleton Class

sreedhar sri

Joined: Sep 05, 2012
Posts: 9
Hi All,

I am new to Webservices. I am developing webservice using axis2-1.6.2. I generated java classes using wsdl file through axis2.
WSDL2Java -uri file:///E:\Desktop\SampleSuscripciones.wsdl -p -d adb -s -wv 1.1 -ss -sd -ssi

After that i generated stub and test class file using the related commands.
WSDL2Java -uri file:///E:\Desktop\SampleSuscripciones.wsdl -p -d adb -s -t

In skelton class i wrote my business logic and used entity manager in this class like the following way.

Service Class:

public class SampleSubscriptionsSkeleton implements SampleSubscriptionsSkeletonInterface{

private EntityManager em;

public getSubscriber
( getSubscriber)
System.out.println("Get subscriber method called in skeleton class:");
Random randNum = new Random();
GetSubscriberResponse resp = new GetSubscriberResponse();
System.out.println("Get Subscriber method called: ");
System.out.println("Entity manager obj in class:"+em);
CriteriaBuilderImpl cb = (CriteriaBuilderImpl)em.getCriteriaBuilder();
System.out.println("Criteria object in Skeleton class:"+cb);
CriteriaQuery<NewSaleSubscriber> criteria = cb.createQuery(NewSaleSubscriber.class);
Root<NewSaleSubscriber> subscriberInfo = criteria.from(NewSaleSubscriber.class);
Predicate predicate =cb.equal(subscriberInfo.get("available"), 1);
List<NewSaleSubscriber> ResultList = em.createQuery(;
NewSaleSubscriber result= ResultList.get(randNum.nextInt(ResultList.size()));
SubscriberInfoType stype= new SubscriberInfoType();

return resp;

//TODO : fill this with the necessary business logic
//throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#getSubscriber");

After this i generated .aar file using build. And uploaded .aar file in axis2 war in GlassFish server. The service is up and running.
In cient class while accessing the service it is giving the error in service class the entity manager object is null.

Client Class:
public class SampleSubscriptionsTest {

public static void main(String args[]) throws java.lang.Exception{

SampleSubscriptionsStub stub =
new SampleSubscriptionsStub ("http://sreedhar-cbd35e:9090/axis2/services/SampleSubscriptions");


public static void doInOnly(SampleSubscriptionsStub stub){
GetSubscriber req = new GetSubscriber();
GetSubscriberResponse resp= new GetSubscriberResponse();
AuthorizationType type;
type=new AuthorizationType();
System.out.println("Response not null:");
System.out.println("Response is null");

} catch(Exception e){


The problem is EntityManager is not injected in Skeleton class. Please any one give the suggestion to solve this problem.

Don't get me started about those stupid light bulbs.
subject: EntityManager is not loaded in Axis2 WebService Skeleton Class
Similar Threads
Creating webservice using Axis2
Axis2 Soap envelope not generating required namespaces.
Facing Problems Running My First WebService
Generate a WS from Spring Service
Not able to hit the webservice when deployed in tomcat.