You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/07/03 02:26:59 UTC

[GitHub] [shardingsphere] lcx1989210 opened a new issue #6248: NPE occured at shardingsphere version 4.1.1

lcx1989210 opened a new issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248


   
   When I update the shardingsphere to 4.1.1, then I found NPE exception when exceute query sql .
   Mysql Server version : 5.7.22;
   shardingsphere version: 4.1.1
   The maven info as follow:
    <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-core-common</artifactId>
               <version>4.1.1</version>
           </dependency>
   
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-core</artifactId>
               <version>4.1.1</version>
           </dependency>
   
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-namespace</artifactId>
               <version>4.1.1</version>
           </dependency>
   
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-orchestration-spring-namespace</artifactId>
               <version>4.1.1</version>
           </dependency>
   
   My query sql is 'select  id,user_id  from order  where order_code = ?   and user_id = ?   and user_type = ?', then I expect is will return some result as normal,but it occure  NPE exception when execute query sql.
   The full exception stacks as follow:
   org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
   ### Error querying database.  Cause: java.lang.NullPointerException
   ### The error may exist in file [/opt/mappers/resource/OrderMapper.xml]
   ### The error may involve defaultParameterMap
   ### The error occurred while setting parameters
   ### SQL: select         id,user_id         from order         where order_code = ?         and user_id = ?         and user_type = ?
   ### Cause: java.lang.NullPointerException
   	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)
   	at com.sun.proxy.$Proxy79.selectOne(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:167)
   	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
   	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
   	at com.sun.proxy.$Proxy82.selectOrderByOrderCode(Unknown Source)
   	at newbiz.impl.OrderServiceBizImpl.createOrder(OrderServiceBizImpl.java:541)
   	at newbiz.impl.OrderServiceBizImpl$$FastClassBySpringCGLIB$$ce562327.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
   	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
   	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
   	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
   	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
   	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
   	at newbiz.impl.OrderServiceBizImpl$$EnhancerBySpringCGLIB$$56e0c385.createOrder(<generated>)
   	at resource.components.OrderService.createOrder(OrderService.java:269)
   	at resource.components.OrderService$$FastClassBySpringCGLIB$$ab928388.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
   	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:84)
   	at resource.aop.ValidateAspect.around(ValidateAspect.java:62)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:497)
   	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
   	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
   	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
   	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
   	at resource.components.OrderService$$EnhancerBySpringCGLIB$$fa556dc9.createOrder(<generated>)
   	at OrderServiceProxyStub1593661232309.createOrder(OrderServiceProxyStub1593661232309.java)
   	at OrderServiceProxyStub1593661232309.invoke(OrderServiceProxyStub1593661232309.java) 
   	at server.core.proxy.InvokerBase.doInvoke(InvokerBase.java:110)
   	at server.core.proxy.AsyncInvokerHandle$1.run(AsyncInvokerHandle.java:101)
   	at server.util.expandasync.AsyncWorker.execTimeoutTask(AsyncWorker.java:139)
   	at server.util.expandasync.AsyncWorker.access$200(AsyncWorker.java:14)
   	at server.util.expandasync.AsyncWorker$executeThread.run(AsyncWorker.java:165)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   	at java.lang.Thread.run(Thread.java:745)
   Caused by: org.apache.ibatis.exceptions.PersistenceException: 
   ### Error querying database.  Cause: java.lang.NullPointerException
   ### The error may exist in file [/opt/mappers/resource/OrderMapper.xml]
   ### The error may involve defaultParameterMap
   ### The error occurred while setting parameters
   ### SQL: select         id,user_id         from order         where order_code = ?         and user_id = ?         and user_type = ?
   ### Cause: java.lang.NullPointerException
   	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:497)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
   	... 49 more
   Caused by: java.lang.NullPointerException
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitEscapedTableReference(MySQLDMLVisitor.java:496)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitEscapedTableReference(MySQLDMLVisitor.java:127)
   	at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$EscapedTableReferenceContext.accept(MySQLStatementParser.java:5947)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitTableReferences(MySQLDMLVisitor.java:489)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitTableReferences(MySQLDMLVisitor.java:127)
   	at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$TableReferencesContext.accept(MySQLStatementParser.java:5891)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitFromClause(MySQLDMLVisitor.java:481)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitFromClause(MySQLDMLVisitor.java:127)
   	at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$FromClauseContext.accept(MySQLStatementParser.java:5846)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelectClause(MySQLDMLVisitor.java:334)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelectClause(MySQLDMLVisitor.java:127)
   	at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$SelectClauseContext.accept(MySQLStatementParser.java:4551)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitUnionClause(MySQLDMLVisitor.java:322)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitUnionClause(MySQLDMLVisitor.java:127)
   	at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$UnionClauseContext.accept(MySQLStatementParser.java:4446)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelect(MySQLDMLVisitor.java:314)
   	at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelect(MySQLDMLVisitor.java:127)
   	at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$SelectContext.accept(MySQLStatementParser.java:3098)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:80)
   	at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:61)
   	at org.apache.shardingsphere.underlying.route.DataNodeRouter.createRouteContext(DataNodeRouter.java:97)
   	at org.apache.shardingsphere.underlying.route.DataNodeRouter.executeRoute(DataNodeRouter.java:89)
   	at org.apache.shardingsphere.underlying.route.DataNodeRouter.route(DataNodeRouter.java:76)
   	at org.apache.shardingsphere.underlying.pluggble.prepare.PreparedQueryPrepareEngine.route(PreparedQueryPrepareEngine.java:54)
   	at org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.executeRoute(BasePrepareEngine.java:96)
   	at org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.prepare(BasePrepareEngine.java:83)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.prepare(ShardingPreparedStatement.java:183)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:143)
   	at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:497)
   	at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
   	at com.sun.proxy.$Proxy103.execute(Unknown Source)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
   	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
   	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
   	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
   	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
   	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
   	... 56 more
   
   The reason NPE exception is that my table name order is a key word in mysql. The solution is rename my table name or use `order` instead of it.
    It is inappropriate for  the NPE exception return to user ,so You can optimize it to give user a appropriate return value。
    
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653321873


   > @lcx1989210 Hi, I want to make sure the relevant SQL is `My query sql is 'select id,user_id from order where order_code = ? and user_id = ? and user_type = ?'`, right?
   > 
   > @jingshanglu Could you review this SQL and test whether is OK on our master branch?
   
   Ok, i'll check.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lcx1989210 commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
lcx1989210 commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653372930


   Why the table name order executed normally at version 3.1.0?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653319629


   @lcx1989210 Hi, I want to make sure the relevant SQL is `My query sql is 'select id,user_id from order where order_code = ? and user_id = ? and user_type = ?'`, right? 
   
   @jingshanglu Could you review this SQL and test whether is OK on our master branch?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lcx1989210 commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
lcx1989210 commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653329299


   @jingshanglu Yes,my query sql is  select id,user_id from order where order_code = ? and user_id = ? and user_type = ?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero closed issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653434608


   @jingshanglu Thanks for detailed feedback. :-) Since this issue was fixed on our master branch, I will close it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yu199195 commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
yu199195 commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653433499


   @lcx1989210  in weixin group ,Haven't you solved it already?   `order` is keyword of mysql.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653367644


   @tristaZero @lcx1989210 Now ,"order" is a keyword, plz use "`order`", and the sql is ok on master branch.
   ![image](https://user-images.githubusercontent.com/16559542/86436775-81fd5100-bd35-11ea-8e5c-b5ff43153921.png)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653434608


   @jingshanglu Thanks for detailed feedback. :-)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #6248: NPE occured at shardingsphere version 4.1.1

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #6248:
URL: https://github.com/apache/shardingsphere/issues/6248#issuecomment-653433955


   @lcx1989210 Sorry for that, In order to support more SQLs and standardize SQL parsing, we refactored sharding parser from 4.x release.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org