apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.34k stars 8.78k forks source link

seata-server not support spring boot3 #5262

Open yuluo-yx opened 1 year ago

yuluo-yx commented 1 year ago

Ⅰ. Issue Description

version:

JDK:17 spring-boot:3.0.2 seata-server:1.5.0

Ⅱ. Describe what happened

Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Exception in thread "main" java.lang.IllegalArgumentException: Unable to instantiate factory class [com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer] for factory type [org.springframework.context.ApplicationContextInitializer]
    at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$throwing$0(SpringFactoriesLoader.java:650)
    at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$handleMessage$3(SpringFactoriesLoader.java:674)
    at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:231)
    at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:206)
    at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:160)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:459)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:455)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:273)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:252)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at indi.yuluo.seata.seatademo.SeataDemoApplication.main(SeataDemoApplication.java:12)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at org.springframework.core.io.support.SpringFactoriesLoader$FactoryInstantiator.instantiate(SpringFactoriesLoader.java:381)
    at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:228)
    ... 9 more
Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to load instance for com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory!
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInstance(SpringInjector.java:40)
    at com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer.<init>(ApolloApplicationContextInitializer.java:67)
    ... 16 more
Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to initialize Apollo Spring Injector!
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInjector(SpringInjector.java:24)
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInstance(SpringInjector.java:37)
    ... 17 more
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.ExceptionInInitializerError
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2048)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3952)
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4964)
    at com.google.inject.internal.FailableCache.get(FailableCache.java:48)
    at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
    at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:138)
    at com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:536)
    at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run(AbstractBindingProcessor.java:160)
    at com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:44)
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:123)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
    at com.google.inject.Guice.createInjector(Guice.java:99)
    at com.google.inject.Guice.createInjector(Guice.java:73)
    at com.google.inject.Guice.createInjector(Guice.java:62)
    at com.ctrip.framework.apollo.spring.util.SpringInjector.getInjector(SpringInjector.java:22)
    ... 18 more
Caused by: java.lang.ExceptionInInitializerError
    at com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73)
    at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:206)
    at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)
    at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:252)
    at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:203)
    at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:53)
    at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:158)
    at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:90)
    at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
    at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
    at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
    at com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3528)
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2277)
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2154)
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2044)
    ... 34 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @7bba5817
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:52)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:42)
    ... 50 more

Process finished with exit code 1

I added the jvm parameter:I--add-opens java.base/java.lang=ALL-UNNAMED A new exception has occurred:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
23:17:55.298 ERROR --- [                     main] o.s.boot.SpringApplication               : Application run failed
==>
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [io.seata.console.config.WebSecurityConfig]: Unresolvable class definition for class [io.seata.console.config.WebSecurityConfig]
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:524)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:304)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:243)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:297)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:243)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:196)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:164)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:398)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:283)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:344)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:115)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:745)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at indi.yuluo.seata.seatademo.SeataDemoApplication.main(SeataDemoApplication.java:12)
Caused by: java.lang.IllegalArgumentException: Unresolvable class definition for class [io.seata.console.config.WebSecurityConfig]
    at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:330)
    at org.springframework.security.config.annotation.method.configuration.GlobalMethodSecuritySelector.selectImports(GlobalMethodSecuritySelector.java:51)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:495)
    ... 20 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/security/config/annotation/web/configuration/WebSecurityConfigurerAdapter
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:467)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:283)
    at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:323)
    ... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 35 common frames omitted
<==

23:17:55.302  WARN --- [                 Thread-0] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
23:17:55.303  WARN --- [                 Thread-0] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Destruction of the end

Process finished with exit code 1

Ⅲ. Describe what you expected to happen

The seata service starts normally

Ⅳ. How to reproduce it (as minimally and precisely as possible)

Please see: https://github.com/yuluo-yx/seata-demo.git

funky-eyes commented 1 year ago

use 1.6.2

yuluo-yx commented 1 year ago

use 1.6.2

image

yuluo-yx commented 1 year ago

You should be talking about version 1.6.1, right? I switched to the new version and still has problems starting

yuluo-yx commented 1 year ago

41873UZN (LA4%~LXSONKP2

funky-eyes commented 1 year ago

If you are using the client, then 1.6.1 is no problem. If you want to modify the server to support springboot3, then you should complete the support for springboot3 by yourself or wait for community support. In addition, jdk17 itself is already supported on 1.6.

yuluo-yx commented 1 year ago

Are you talking about the client way to download a zip archive from 'https://github.com/seata/seata/releases/tag/v1.6.1'? Does starting the Spring Boot project take the form of server-side startup?

funky-eyes commented 1 year ago

The release note refers to the springboot3 support on the client side, not the server side, because the server side does not involve the user application level, and does not require users to actively modify the code on the server side, so we do not support springboot3 on the server side. Because this is not the focus of community work, nor can it improve the performance of seata-server, because seata-server only uses springboot at the console level

yuluo-yx commented 1 year ago

Allow me to summarize what you said, are you saying that seata does not support starting seata services in the form of spring boot3 services, starting seata clients locally? If I want to start as a Spring Boot service, I need to adapt it myself or wait for community support.

funky-eyes commented 1 year ago

seata client side supports springboot3, and the seata-server does not support springboot3, because users do not need to integrate seata server in their applications

yuluo-yx commented 1 year ago

Thank you for your answer!

funky-eyes commented 1 year ago

If you adapt Seata-Server to Spring-Boot3, the community will accept it, and you are welcome to submit a PR to support, if you want to wait until the main developer support of the community, then the priority is lower

yuluo-yx commented 1 year ago

If you adapt Seata-Server to Spring-Boot3, the community will accept it, and you are welcome to submit a PR to support, if you want to wait until the main developer support of the community, then the priority is lower

If you do, you will need to upgrade the Spring Boot and Spring Framework versions. This is a big change for project.

funky-eyes commented 1 year ago

Yes, so on Seata-Server, its priority is not high, we are currently focusing on the extension and optimization of the capabilities of core transactions

yuluo-yx commented 1 year ago

ok! I'll finish it, and if seata-server starts normally after the upgrade is complete, it will prove successful, right?

funky-eyes commented 1 year ago

You have to try to access port 7091 and verify that the relevant functions of the console are normal

yuluo-yx commented 1 year ago

You have to try to access port 7091 and verify that the relevant functions of the console are normal

ok

yuluo-yx commented 1 year ago

必须尝试访问7091端口,验证控制台相关功能是否正常

please see #5263 image Other errors I fixed locally

yuluo-yx commented 1 year ago

Now, my local tests are successful. Something went wrong in Github's action. Because I'm using jdk17 locally, the mvn command runs normally. But the JDK version given to GitHub is JDK8, so the run failed! There is a comparison relationship about the JDK version of the class file, please see the picture: image image

funky-eyes commented 1 year ago

I see, because spring-boot3 must be built on top of jdk17, which requires the ci to be separated into client and server, and the community requirements for seata-server is that it must support jdk8, but can run on jdk17, if developed entirely based on spring-boot3 will limit seata-server server support jdk version

yuluo-yx commented 1 year ago

我明白了,因为spring-boot3必须建立在jdk17之上,这就要求ci要分client和server,而社区对seata-server的要求是必须支持jdk8,但是开发的话可以跑在jdk17上完全基于spring-boot3会限制seata-server服务器支持jdk版本

Yeah, that's what's going on.

funky-eyes commented 1 year ago

This issue will continue to be discussed in the community, as to when the seata-server will be developed based on springboot3 will depend on the amount of user demand

yuluo-yx commented 1 year ago

这个问题会在社区继续讨论,至于什么时候基于springboot3开发seata-server取决于用户需求量

ok. If possible, my suggestion is to separate the Seata-serve module from the seata project.