记录一次jeecms修改子栏目或子栏目进行排序时,服务请求发生了错误,

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下观察前后两个对象的值也都时一样,有知道的可以说一下,谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值