When upgrading java11 to java17, the project starts normally, and an error is reported when executing the mybatis query
According to the error message, it is suspected that there is a problem with mybatis XML configuration. It is found that there is no problem. Jdk11 starts normally
reating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3c88e19e] was not registered for synchronization because synchronization is not active
JDBC Connection [org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.ShardingConnection@5b6098ff] will not be managed by Spring
==> Preparing: select id, user_id as userId, order_id as orderId, remark, create_time as createTime from t_order where order_id=?
==> Parameters: 12(Long)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3c88e19e]
2021-09-20 22:47:33.431 ERROR 19452 --- [nio-9090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field private static final long java.lang.Number.serialVersionUID accessible: module java.base does not "opens java.lang" to unnamed module @708f5957
### The error may exist in file [D:\java\IdeaProjects\sharding-demo\target\classes\mapper\OrderMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select id, user_id as userId, order_id as orderId, remark, create_time as createTime from t_order where order_id=?
### Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field private static final long java.lang.Number.serialVersionUID accessible: module java.base does not "opens java.lang" to unnamed module @708f5957] with root cause
java.lang.reflect.InaccessibleObjectException: Unable to make field private static final long java.lang.Number.serialVersionUID accessible: module java.base does not "opens java.lang" to unnamed module @708f5957
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:130) ~[na:na]
at org.codehaus.groovy.reflection.CachedClass$1$1.run(CachedClass.java:55) ~[groovy-2.4.5-indy.jar:2.4.5]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:50) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:48) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:49) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:36) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.reflection.CachedClass.getFields(CachedClass.java:264) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaClassImpl.addFields(MetaClassImpl.java:2377) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaClassImpl.inheritFields(MetaClassImpl.java:2372) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaClassImpl.setupProperties(MetaClassImpl.java:2259) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3302) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3266) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:295) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:261) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:873) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:125) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:166) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-2.4.5-indy.jar:2.4.5]
at Script6$_run_closure1.doCall(Script6.groovy:1) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.Closure.call(Closure.java:426) ~[groovy-2.4.5-indy.jar:2.4.5]
at groovy.lang.Closure.call(Closure.java:420) ~[groovy-2.4.5-indy.jar:2.4.5]
at org.apache.shardingsphere.core.strategy.route.inline.InlineShardingStrategy.execute(InlineShardingStrategy.java:94) ~[sharding-core-common-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.core.strategy.route.inline.InlineShardingStrategy.doSharding(InlineShardingStrategy.java:76) ~[sharding-core-common-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.core.strategy.route.inline.InlineShardingStrategy.doSharding(InlineShardingStrategy.java:63) ~[sharding-core-common-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeTables(ShardingStandardRoutingEngine.java:214) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:195) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:121) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:115) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:96) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:74) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.decorate(ShardingRouteDecorator.java:69) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.decorate(ShardingRouteDecorator.java:53) ~[sharding-core-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.underlying.route.DataNodeRouter.executeRoute(DataNodeRouter.java:91) ~[shardingsphere-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.underlying.route.DataNodeRouter.route(DataNodeRouter.java:76) ~[shardingsphere-route-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.underlying.pluggble.prepare.PreparedQueryPrepareEngine.route(PreparedQueryPrepareEngine.java:54) ~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.executeRoute(BasePrepareEngine.java:96) ~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.prepare(BasePrepareEngine.java:83) ~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.prepare(ShardingPreparedStatement.java:183) ~[sharding-jdbc-core-4.1.1.jar:4.1.1]
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:143) ~[sharding-jdbc-core-4.1.1.jar:4.1.1]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.7.jar:3.5.7]
at jdk.proxy3/jdk.proxy3.$Proxy95.execute(Unknown Source) ~[na:na]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) ~[mybatis-3.5.7.jar:3.5.7]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.6.jar:2.0.6]
at jdk.proxy2/jdk.proxy2.$Proxy65.selectList(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) ~[mybatis-spring-2.0.6.jar:2.0.6]
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145) ~[mybatis-3.5.7.jar:3.5.7]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.7.jar:3.5.7]
at jdk.proxy2/jdk.proxy2.$Proxy66.getOrderByOrderId(Unknown Source) ~[na:na]
at com.fancv.shardingdemo.service.impl.OrderServiceImpl.getOrderByOrderId(OrderServiceImpl.java:26) ~[classes/:na]
at com.fancv.shardingdemo.controller.OrderController.getOrderInfo(OrderController.java:42) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]
Search data discovery
Someone is experiencing the same problem when upgrading to jdk9
By adding startup parameters
--add-opens java.base/java.lang=ALL-UNNAMED
Original information
The following error message appears:
Exception in thread “main”
java.lang.reflect.InaccessibleObjectException: Unable to make field
private static final long java.lang.Long.serialVersionUID accessible:
module java.base does not “opens java.lang” to unnamed module
@224aed64
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject.java:207)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:171)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:165)
at com.jdojo.intruder.TestManifestAttributes.main(TestManifestAttributes.java:10)
A runtime error indicates that the application cannot access the private static serialVersionUID because the java.lang package in the java.base module is not open. Let’s try the – add opens option first:C: \ java9revealed & gt; Java — add opens Java. Base/Java. Lang = all unnamed
– jar com.jdojo.intruder \ dist \ com.jdojo.intruder.jar output information is as follows:Long. SerialVersionUID = 4290774380558885855 this command works normally and verify that the command line option is the solution in this case.
we use the add opens attribute in the manifest.mf file to fix this error, as shown below.Manifest version: 1.0 main class:
com.jdojo.intruder.testmanifestattributes add opens:
java.base/java.lang recreate the executable jar and run it with the same command:C: \ java9revealed & gt; Java – jar
com.jdojo.intruder \ dist \ com.jdojo.intruder.jar the output result is:Long.serialVersionUID=4290774380558885855
Run the project again and query the data successfully
Summary: upgrading from java11 to java17 is a personal computer at home, not a production environment,
It takes about 5 hours to solve the problem, because the project is a shared research project, involving many knowledge points, and it takes a long time to locate the problem.
Difficult: the project itself has no problem starting jdk11, but an error is reported after upgrading jdk15.
reference material: https://www.cnblogs.com/IcanFixIt/p/7144366.html
Technical exchange group:
Read More:
- Caused by: java.lang.reflect.InvocationTargetExceptio
- Spock + powermock simulation static method reports an error java.lang.classcastexception
- java.lang.reflect.InvocationTargetException
- [actual record of Android stepping on the pit] Android studio reports an error invalid gradle JDK configuration found after importing the project
- The java.lang.exceptionininitializererror of mybatis reports an error
- java.lang.IllegalArgumentException: Address 127.0.0.1:5672:5672 seems to contain an unquoted IPv6
- Upgrade to IntelliJ idea 2021.2 and start the project with an error
- Error in idea compilation: java.lang.OutOfMemoryError Java heap space and java.lang.StackOverflowError
- Java project cannot import entity class package and service package, controller layer reports error, fix project setup is OK
- The web project removal server reports an error, and the web project in eclipse cannot be automatically deployed to Tomcat
- java.lang.NoSuchMethodError: org.json.JSONObject.put(Java/lang/String; Java/util/Collection;) “209151;”
- Eclipse:An error has occurred. See error log for more details. java.lang.NullPointerException
- The common module of idea Maven parent-child project packages and reports an error
- Mac compiles Doris with MVN and reports an error checkstyle
- Java. Lang. outofmemoryerror when using idea build project
- Eclipse startup error: a Java runtime environment (JRE) or Java Development Kit (JDK) must be available
- Running Django (2.2) project in Python 3.7.9 reports an error
- Junit4 unit test reports an error invalid project specified
- When Jenkins deploys the project, GIT reports an error fatal: index file smaller than expected
- -bash: /usr/java/jdk1.8.0_101/bin/java: Permission denied