Closed godtroop-github closed 1 year ago
This is caused by the fact that spring service runs in IDEA. When spring service runs in IDEA, the class loader changes from LaunchedClassLoader to AppClassLoader and cannot get sermant classes which injected through Inject service. Running through jars should avoid this problem.
This issue seems to be Stale. We will close it in a few days.
A solution has been provided. No other problems will occur in the future. Therefore, this issue is closed.
What happened?
when just clone the repo(develp branch), packaged and deployed the agent plugins, using the router-demo from Sermant-Examples, the program reported a exception after the plugin inited : "java.lang.ClassFormatError:Truncated class file".
but, when I switch to 1.1.x branch, this can get work.
How can we reproduce it (as minimally and precisely as possible)?
1 clone https://github.com/huaweicloud/Sermant.git 2 run mvn clean package, and deployed all the plugin jars to ${dir}/sermant-agent-1.0.0/agent automatically by maven. 3 clone https://github.com/huaweicloud/Sermant-examples.git 4 launch the router-demo(ZuulApplication), using the VM parameter "-javaagent:/Users/Mac/Documents/GitHub/Sermant/sermant-agent-1.0.0/agent/sermant-agent.jar=appName=zuul" 5 when the program start running , this exception will be found
Anything else we need to know?
Something I just found from the source code, is that I am using the "develop" git branch, and there may be a class isolation is being developing. And the PluginManager#loadPlugins class method has some change: after: before:
this may cause define progress can't load the correct class bytes, because the ClassUtils#defineClass only search SystemClassLoader and ContextClassLoader.
I guess may be that's reason for this issue.
Sermant version
OS version
mac os / Apple M2 Max