坚持使用Hibernate的ClassCastException但只偶尔在tomcat上

时间:2014-04-30 07:10:17

标签: java hibernate

我不认为任何人都可以在这里提供帮助,但如果您有任何指示,我将不胜感激。基本上,自从将Tomcat(7)移动到Java 7后,我们有时会得到以下异常。似乎唯一可以解决它的问题是重新启动tomcat。我不能在我的机器上本地重现它,所以我知道所有的映射等都很好。我想知道是否有人有任何想法?

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of hub.app.model.DocumentFolder.id
 at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
 at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
 at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3596)
 at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3312)
 at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
 at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:348)
 at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
 <snip>
 Caused by: 
 java.lang.IllegalArgumentException: java.lang.ClassCastException@18b0170
 at sun.reflect.GeneratedMethodAccessor754.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
 at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
 at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3596)
 at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3312)
 at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
 at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:348)
 at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
 at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
 at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
 at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
 at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
 at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
 at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1136)
 at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
 at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:49)
 at hub.app.model.dao.EntityAccessCountHibernateDAO.addAccessCount(EntityAccessCountHibernateDAO.java:33)
 at hub.app.model.dao.EntityAccessCountHibernateDAO$$EnhancerByGuice$$3ea802fe.CGLIB$addAccessCount$0(<generated>)
 at hub.app.model.dao.EntityAccessCountHibernateDAO$$EnhancerByGuice$$3ea802fe$$FastClassByGuice$$64e6ae4b.invoke(<generated>)
 at com.google.inject.internal.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
 at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
 at com.wideplay.warp.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:68)
 at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
 at com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:44)
 at hub.app.model.dao.EntityAccessCountHibernateDAO$$EnhancerByGuice$$3ea802fe.addAccessCount(<generated>)
 at hub.app.service.hotstuff.HotStuffService.recordAccess(HotStuffService.java:40)

编辑: 我刚刚在另一个tomcat实例上再次使用它。这次异常略有不同:

Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of hub.app.model.DocumentFolder.id
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
    at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3596)
    at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3312)
    at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
    at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:348)
    at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
    at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
    at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
    ... 19 more
 Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    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:606)
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
    ... 33 more

0 个答案:

没有答案