实体类的getHibernateLazyInitializer中的NullPointerException

时间:2013-11-29 14:59:53

标签: java hibernate javassist

我遇到以下异常:

     java.lang.NullPointerException 
     at javassist.util.proxy.RuntimeSupport$DefaultMethodHandler.invoke(RuntimeSupport.java:38)
     at com.Customer_$$_javassist_1.getHibernateLazyInitializer(Customer_$$_javassist_1.java)
     at org.hibernate.Hibernate.isInitialized(Hibernate.java:429)
     at org.hibernate.engine.StatefulPersistenceContext.reassociateIfUninitializedProxy(StatefulPersistenceContext.java:530)
     at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.reassociateIfUninitializedProxy(DefaultSaveOrUpdateEventListener.java:99)
     at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:82)
     at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
     at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
     at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:673)
     at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:740)
     at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
     at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
     at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
     at com.HibernateCustomerService.create(HibernateCustomerService.java:31)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:616)
     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
     at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
     at sun.proxy.$Proxy62.create(Unknown Source)

这往往是在中等/高负载下应用程序启动后不久发生的。进一步实例化com.Customer类失败并出现相同的异常,因此在我们重新启动之前应用程序会被有效地破坏。

我已经跟踪了代码,无法看到DefaultMethodHandler如何在theCustomer_$$_javassist_1中调用JavassistLazyInitializer,因为它是在{{1}}中设置的。

这是在使用javassist 3.16.1

的Hibernate 3.6.8-Final上

有没有人见过这个?有没有可行的解决方法?

0 个答案:

没有答案