Closed Self-revolution closed 1 month ago
/seata-server/libs/jdbc
我看1.8.0版本中驱动jar包确实在/seata-server/libs/jdbc
目录下,但我将挂载方式改为-v "$directory"/mysql-connector-java-8.0.30.jar:/seata-server/libs/jdbc/mysql-connector-java.jar
,还是报同样的错误。
我甚至将1.8.0中的/seata-server/libs/jdbc
目录拷贝出来,再挂载到2.1.0版本的/seata-server/libs/jdbc
目录下,还是报同样的错误
抱歉,容器镜像的依赖确实在lib中,你试试把driver直接放到lib下,看看结果如何? Sorry, the container image dependencies are indeed in lib. Try placing the driver directly in the lib directory and see how it goes.
我怀疑这有一个bug,异常日志在main线程输出,可以看到触发该异常的线程的classloader是main线程的classloader。 而seata去加载driver用的是MysqlDriverClassLoader。 mian线程里面校验driver是否存在用的是main线程的classloader,如何能加载到mysql的driver进行正确校验呢?(其它数据库的driver都在lib下,只有mysql放到了jdbc中) I suspect there might be a bug. The exception logs are output on the main thread, and you can see that the class loader of the thread triggering the exception is the main thread's class loader. However, Seata uses MysqlDriverClassLoader to load the driver. In the main thread, the driver existence check is performed using the main thread's class loader. How can it correctly verify the MySQL driver if the driver is loaded with a different class loader? (Other database drivers are in lib, but only MySQL is placed in jdbc.)
临时解决方法,在lib和lib/jdbc都加上这个driver的jar就可以解决该问题了。 https://github.com/apache/incubator-seata/pull/6332 原因是这个pr增加了校验,却没有将classloader统一导致的,将在2.2上解决该问题。 A temporary solution is to add the driver's JAR to both lib and lib/jdbc, which will resolve the issue. The reason is that this PR introduced additional checks but did not unify the class loaders, leading to the problem. This will be addressed in version 2.2
问题解决!
-v "$pwd"/mysql-connector-j-8.4.0.jar:/seata-server/libs/mysql-connector-j-8.4.0.jar
我只在/seata-server/libs/
目录下挂载了驱动,并没有在/seata-server/libs/jdbc
目录下挂载驱动,是可以正常启动的
临时解决方法,在lib和lib/jdbc都加上这个driver的jar就可以解决该问题了。 #6332 原因是这个pr增加了校验,却没有将classloader统一导致的,将在2.2上解决该问题。 A temporary solution is to add the driver's JAR to both lib and lib/jdbc, which will resolve the issue. The reason is that this PR introduced additional checks but did not unify the class loaders, leading to the problem. This will be addressed in version 2.2
我只在
/seata-server/libs/
目录下挂载了驱动,并没有在/seata-server/libs/jdbc
目录下挂载驱动,是可以正常启动的临时解决方法,在lib和lib/jdbc都加上这个driver的jar就可以解决该问题了。 #6332 原因是这个pr增加了校验,却没有将classloader统一导致的,将在2.2上解决该问题。 A temporary solution is to add the driver's JAR to both lib and lib/jdbc, which will resolve the issue. The reason is that this PR introduced additional checks but did not unify the class loaders, leading to the problem. This will be addressed in version 2.2
libs下也可以通用的,实际上jdbc那个只是为了做多版本driver加载用的,里面放5.1.x和8.x的driver,你只有一个driver实际上不放在jdbc下也可以 It can also be used universally under libs. In fact, the jdbc one is only for multi-version driver loading. There are 5.1.x and 8.x drivers in it. You only have one driver. In fact, it can be placed under jdbc.
意思是如果有5.1.x和8.x两个driver,需要在/seata-server/libs/
目录和/seata-server/libs/jdbc
目录都加载驱动jar包是吗
I would like to claim this task
Ⅰ. Issue Description
启动
apache/seata-server:2.1.0.jre17
镜像时,无法加载mysql驱动,我尝试将mysql-connector-java-8.0.30.jar
和mysql-connector-j-8.4.0.jar
挂载到/lib/jdbc目录下,但还是报错Ⅱ. Describe what happened
启动脚本:
报错内容:
我将版本修改为seataio/seata-server:1.8.0.jre17,进入镜像后,可以看到我的脚本确实可以将驱动jar包挂载到/lib/jdbc目录下