mybatis 并發執行時出現NullPointerException

AlbertoGFS 4年前發布 | 50K 次閱讀 Java MyBatis

異常堆棧如下:

### Cause: java.lang.NullPointerException
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)
        at sun.reflect.GeneratedMethodAccessor725.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
        ... 87 more
Caused by: java.lang.NullPointerException
        at org.apache.ibatis.reflection.property.PropertyTokenizer.<init>(PropertyTokenizer.java:27)
        at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:114)
        at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextMap.get(DynamicContext.java:89)
        at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:107)
        at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
        at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
        at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
        at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
        at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)
        at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
        at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
        at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
        at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
        at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
        at org.apache.ibatis.builder.xml.dynamic.OgnlCache.getValue(OgnlCache.java:42)
        at org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
        at org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:30)
        at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)
        at org.apache.ibatis.builder.xml.dynamic.TrimSqlNode.apply(TrimSqlNode.java:42)
        at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)
        at org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:37)
        at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:241)
        at org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:61)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:36)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:42)
        at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:348)
        at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:43)
        at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
        at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
        ... 92 more

這是mybatis依賴包OGNL 2.6.9的一個bug,可以通過升級mybatis版本到 3.3.0來解決此問題。

mybatis官方issue說明: https://github.com/mybatis/mybatis-3/issues/224

 本文由用戶 AlbertoGFS 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
個評論