jeecms使用版本 v8,其他版本若有这个问题,应该也适用
异常信息:
29-May-2019 11:18:58.206 严重 [http-nio-8088-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [JeeCmsAdmin] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at com.jeecms.common.hibernate4.TreeIntercptor.updateParent(TreeIntercptor.java:135)
at com.jeecms.common.hibernate4.TreeIntercptor.onFlushDirty(TreeIntercptor.java:124)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.invokeInterceptor(DefaultFlushEntityEventListener.java:365)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:342)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:293)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:160)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy31.update(Unknown Source)
at com.jeecms.cms.action.admin.main.ChannelAct.update(ChannelAct.java:413)
at com.jeecms.cms.action.admin.main.ChannelAct$$FastClassBySpringCGLIB$$e67da54.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
异常代码:TreeIntercptor.java
if ((preParent == null && currParent == null) || (preParent != null && currParent != null && preParent.getId().equals(currParent.getId()))) {
return false;
}
由于 preParent.getId()值为 null 造成的 空指针异常,开始怀疑懒加载,hibernate 代理等问题,百度各种回答未解决问题
解决办法:
if ((preParent == null && currParent == null)
|| (preParent != null && currParent != null && ((Channel)preParent).getId().equals(((Channel)currParent).getId()))) {
return false;
}
将preParent 和 currParent 强转为Channel 对象
至于为什么强转之后能够通过getId()获取到值,暂不清除原因,debug下观察前后两个对象的值也都时一样,有知道的可以说一下,谢谢