Issue with Hibernate 3

20 views
Skip to first unread message

kerrin

unread,
May 19, 2006, 6:38:55 AM5/19/06
to Java Web Application
I'm having problems with hibernate, it's a strange one.

I have two layers: a manager and a service layer, and I have test rigs
for each, the manager layer simply sets up the session and transacton
(if required) and calls the service layer.

e.g. Manager Layer

public static Thing getThing(int thingId)
{
Session session = SessionUtil.getInstance().getSession(); // Simply
gets an open session from the pool
Thing thing = ServiceLayer.getThing(session, thingId);
session.close();
return thing;
}

The problem is the test rig for the service layer passes 100%, but
almost exactly the same test rig code (I changed service to manager,
and don't pass in the session) that calls the manager layer fails with
the following error when ever I insert and then try to get a row:


java.lang.NullPointerException
at
org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at
org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
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:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
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:116)
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:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at
com.recruitment.job.service.JobDBService.deleteJob(JobDBService.java:99)
at
com.recruitment.job.service.JobDBManager.deleteJob(JobDBManager.java:144)
at
testcom.recruitment.job.service.TestJobDBManager.testCreateJob(TestJobDBManager.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:289)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:656)
at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:558)


I suspect it may be that there is a deadlock, but I commit any changes
in the manager layer functions and close the session each time.

Help, I am stumped on this one.

Kerrin

kerrin

unread,
May 19, 2006, 9:49:24 AM5/19/06
to Java Web Application
I'd already been fighting this error for over a day before I posted.

The good news is I have finally tracked the problem down.

in my hibernate.properties file I had the following:

hibernate.connection.pool_size 1

So when I tried to use a second session it would fail (only on selects
though)

I increased it, and the problem has gone away. Shame java errors are so
useless sometimes!

Reply all
Reply to author
Forward
0 new messages