主题: ERROR:backend connect: java.lang.NullPointerExcep

a1057718341 2020年02月18日 38

项目架构: springcloud + durid + beetlsql + mycat +mysql6.7

以下问题操作步骤:

1、查询数据 没问题,然后修改数据,执行更新,抛出异常如下:

image.png


数据源配置:

image.png

image.png

数据库配置:

image.png

以上问题偶然发生,查阅下相关资料及跟踪源码,怀疑是mysql 8小时链接失效导致,在项目启动时获取的链接虽然有效,但是真实情况已经断了,导致执行报错。查阅durid官网,修改配置如上进行测试,问题依旧。

闲大赋 2020年02月18日

这个貌似是druid的一个问题,还有更详细的错误提示吗?建议换,比如springboot 内置和推荐的HikariCP

a1057718341 2020年02月18日

2020-02-18 18:18:36.461 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-1] druid.sql.Statement : {conn-10002, pstmt-20005} clearParameters. 2020-02-18 18:18:36.461 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-1] c.a.druid.pool.PreparedStatementPool : {conn-10002, pstmt-20005} exit cache2020-02-18 18:18:36.462 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-1] druid.sql.Statement : {conn-10002, pstmt-20005} closed2020-02-18 18:18:36.510 ERROR [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-4] druid.sql.Statement : {conn-10001, pstmt-20004} execute error.     UPDATE  p_org_sub_order    SET lastModifyTime = CURRENT_DATE(), lastModifyUser = ?, lockStock = ?, disposeStatus = ?, pushStatus = ?, pushTime = ?      WHERE id = ?java.sql.SQLException: backend connect: java.lang.NullPointerException at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079) at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013) at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3253) at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1092) at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) at com.alibaba.druid.wall.WallFilter.preparedStatement_executeUpdate(WallFilter.java:662) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) at com.alibaba.druid.filter.FilterAdapter.preparedStatement_executeUpdate(FilterAdapter.java:1092) at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeUpdate(FilterEventAdapter.java:491) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeUpdate(FilterChainImpl.java:3251) at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeUpdate(PreparedStatementProxyImpl.java:194) at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:255) at org.beetl.sql.core.SQLScript.update(SQLScript.java:472) at org.beetl.sql.core.SQLManager.update(SQLManager.java:1450) at org.beetl.sql.core.mapper.UpdateMapperInvoke.call(UpdateMapperInvoke.java:21) at org.beetl.sql.core.mapper.MapperJavaProxy.invoke(MapperJavaProxy.java:163) at org.beetl.sql.core.mapper.MapperJava8Proxy.invoke(MapperJava8Proxy.java:92) at com.sun.proxy.$Proxy179.updateRecord(Unknown Source) at com.wbs.order.bussiness.apps.distribution.service.impl.DistributionOrderToWareServiceImpl.checkOrderProdStock(DistributionOrderToWareServiceImpl.java:256) at com.wbs.order.bussiness.apps.distribution.service.impl.DistributionOrderToWareServiceImpl.handleCheckOrderProdStock(DistributionOrderToWareServiceImpl.java:161) at com.wbs.order.bussiness.apps.distribution.service.impl.DistributionOrderToWareServiceImpl$$FastClassBySpringCGLIB$$167d5286.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.wbs.order.bussiness.apps.distribution.service.impl.DistributionOrderToWareServiceImpl$$EnhancerBySpringCGLIB$$8fd289d7.handleCheckOrderProdStock(<generated>) 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:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206) at com.sun.proxy.$Proxy190.handleCheckOrderProdStock(Unknown Source) at com.wbs.order.bussiness.apps.distribution.service.impl.BackOrderServiceImpl.handlerSplitOrderForBack2(BackOrderServiceImpl.java:187) at com.wbs.order.bussiness.apps.distribution.service.impl.BackOrderServiceImpl.handlerSplitOrderForBack(BackOrderServiceImpl.java:140) at com.wbs.order.bussiness.apps.distribution.service.impl.BackOrderServiceImpl$$FastClassBySpringCGLIB$$19b9761.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.wbs.order.bussiness.apps.distribution.service.impl.BackOrderServiceImpl$$EnhancerBySpringCGLIB$$4a45b948.handlerSplitOrderForBack(<generated>) 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:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy191.handlerSplitOrderForBack(Unknown Source) at com.wbs.order.bussiness.apps.distribution.service.impl.SplitOrderServiceImpl.verifySendToWare(SplitOrderServiceImpl.java:824) at com.wbs.order.bussiness.apps.distribution.service.impl.SplitOrderServiceImpl$$FastClassBySpringCGLIB$$48f26dce.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.wbs.order.bussiness.apps.distribution.service.impl.SplitOrderServiceImpl$$EnhancerBySpringCGLIB$$c37928af.verifySendToWare(<generated>) 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:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:73) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy193.verifySendToWare(Unknown Source) at com.wbs.order.bussiness.apps.distribution.mq.MqReWareSubOrderService.verifySendToWare(MqReWareSubOrderService.java:216) at com.wbs.order.bussiness.apps.distribution.mq.MqReWareSubOrderService$1.handler(MqReWareSubOrderService.java:123) at com.wbs.order.bussiness.apps.distribution.mq.ReadMQHandler.readMq(ReadMQHandler.java:25) at com.wbs.order.bussiness.apps.distribution.mq.MqReWareSubOrderService.receiveObjectDel(MqReWareSubOrderService.java:130) 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:498) at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:170) at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:120) at org.springframework.amqp.rabbit.listener.adapter.HandlerAdapter.invoke(HandlerAdapter.java:49) at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:190) at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:127) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1547) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1473) 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:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at brave.spring.rabbit.TracingRabbitListenerAdvice.invoke(TracingRabbitListenerAdvice.java:74) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:91) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:180) at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:115) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at org.springframework.amqp.rabbit.listener.$Proxy242.invokeListener(Unknown Source) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1461) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1456) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1405) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:870) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:854) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1600(SimpleMessageListenerContainer.java:78) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.mainLoop(SimpleMessageListenerContainer.java:1137) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1043) at java.lang.Thread.run(Thread.java:748)2020-02-18 18:18:36.514 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-1] druid.sql.Connection : {conn 10002} rollback2020-02-18 18:18:36.515 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-1] druid.sql.Connection : {conn-10002} setAutoCommit true┏━━━━━ Debug [pOrgSubOrder.updateRecord] ━━━┣ SQL:   UPDATE p_org_sub_order SET lastModifyTime = CURRENT_DATE(), lastModifyUser = ?, lockStock = ?, disposeStatus = ?, pushStatus = ?, pushTime = ? WHERE id = ? ┣ 参数: [系统自动, 0, 5, 0, 2020-02-18 18:18:25.037, b9cd3c4d9450406ea60306dc9aa9073c]┣ 位置: com.wbs.order.bussiness.apps.distribution.service.impl.DistributionOrderToWareServiceImpl.checkOrderProdStock(DistributionOrderToWareServiceImpl.java:256)┗━━━━━ Debug [ ERROR:backend connect: java.lang.NullPointerException] ━━━2020-02-18 18:18:36.517 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-4] druid.sql.Statement : {conn-10001, pstmt-20004} clearParameters. 2020-02-18 18:18:36.517 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-4] c.a.druid.pool.PreparedStatementPool : {conn-10001, pstmt-20004} exit cache2020-02-18 18:18:36.518 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-4] druid.sql.Statement : {conn-10001, pstmt-20004} closed2020-02-18 18:18:36.570 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-4] druid.sql.Connection : {conn 10001} rollback2020-02-18 18:18:36.570 DEBUG [wbs-order-split-distribution] [192.168.0.16:8765] [SimpleAsyncTaskExecutor-4] druid.sql.Connection : {conn-10001} setAutoCommit true


这是全部日志信息

a1057718341 2020年02月18日

更换为HikariCP  数据源

<!-- HikariCP 连接池依赖,从父依赖获取额版本 --><dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <version>3.1.0</version></dependency>

通过以上数据源测试,问题依旧不能解决。

闲大赋 2020年02月19日

如果错误提示还是这样,考虑换个驱动看看呢,另外,换成HikariCP,错误提示变成什么样了?

闲大赋 2020年02月19日

既然用了mycat,可以询问一下mycat,这个错误跟beetlsql没啥关系,因为如果发送错误的sql或者参数,驱动必然会返回一个正常异常,这个空指针异常已经表示 mysql的驱动处理bug。