Hi I have some code that loads a "Person" object and calls a method getTrips() which returns a Set of trips. This code was working fine in a command line based app but in my webapp deployed on Sun Appserver i get an NPE. The stacktrace is included after the code.. I observed that the exception occurs when i call the getTrips() method on the Person object.. . can anyone give me some pointers on this.. maybe the mapping files have a bug? not sure....
Thanks
Saniya
Code:
Session session = travelcenterhibernate.HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
travelcenterhibernate.Person person = (travelcenterhibernate.Person)session.load(travelcenterhibernate.Person.class, personId);
System.err.println("Person Information: "+ " Person Name "+ person.getName()+ " JobTitle: "+ person.getJobTitle() );
System.err.println("Person Trips Information: Found ");
java.util.Set personTrips = (org.hibernate.collection.PersistentSet)person.getTrips();
System.out.println("Total Trips" + personTrips.size());
Iterator iterator = personTrips.iterator();
while(iterator.hasNext()){
travelcenterhibernate.Trip temp = (Trip)iterator.next();
System.err.println(" \n TripId: "+temp.getTripId()+ " DestCity: "+ temp.getDepCity()+ " TripType: "+temp.getTripType().getName());
}
=====================================
stacktrace from the exception...
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3120)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:812)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:782)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1493)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:109)
at org.hibernate.collection.PersistentSet.size(PersistentSet.java:114)
at travelcenterhibernateweb.SessionBean1.getPersonsTrips(SessionBean1.java:171)
|#][/code]