HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.37k stars 493 forks source link

While starting the server I'm getting compile error: no such class: org.hotswap.agent.config.PluginManager #334

Open omer727 opened 4 years ago

omer727 commented 4 years ago

Hey, I'm using hotswap-agent-1.3.0.jar using the latest hotswap intellij plugin on windows. using the following command line _"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:1189,suspend=y,server=n -Dsa_config_dir=C:\mqm\site -Dcom.hp.mqm.runners.jetty.jetty_jmx_enable=true -javaagent:C:\Users\.IntelliJIdea2019.3\system\groovyHotSwap\gragent.jar -XXaltjvm=dcevm -javaagent:C:\Users\\Downloads\hotswap-agent-1.3.0.jar -javaagent:C:\Users\.IntelliJIdea2019.3\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.3\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\\AppData\Local\Temp\ideaclasspath1692263943.

The process works in the end, and I'm able to debug and do hotswap whenever I build the java class. The problem is when starting the server I keep getting the following exception 9 times, each time for a different plugin.

HOTSWAP AGENT: 08:48:46.607 ERROR (org.hotswap.agent.annotation.handler.PluginClassFileTransformer) - InvocationTargetException in transform method on plugin 'class org.hotswap.agent.plugin.log4j2.Log4j2Plugin' class 'org/apache/logging/log4j/core/LoggerContext'. java.lang.reflect.InvocationTargetException 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.hotswap.agent.annotation.handler.PluginClassFileTransformer.transform(PluginClassFileTransformer.java:193) at org.hotswap.agent.annotation.handler.PluginClassFileTransformer.transform(PluginClassFileTransformer.java:89) at org.hotswap.agent.util.HotswapTransformer.transform(HotswapTransformer.java:184) at sun.instrument.TransformerManager.transform(TransformerManager.java:188) at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121) at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43) at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46) at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270) at org.eclipse.jetty.util.log.Slf4jLog.(Slf4jLog.java:36) at org.eclipse.jetty.util.log.Slf4jLog.(Slf4jLog.java:30) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.eclipse.jetty.util.log.Log.initialized(Log.java:157) at org.eclipse.jetty.util.log.Log.getLogger(Log.java:276) at org.eclipse.jetty.util.log.Log.getLogger(Log.java:265) at org.eclipse.jetty.util.component.AbstractLifeCycle.(AbstractLifeCycle.java:35) at com.hp.mqm.runners.jetty.Jetty.boot(Jetty.java:63) at com.hp.mqm.boot.Bootstrap.boot(Bootstrap.java:10) at com.hp.mqm.MqmServer.main(MqmServer.java:17) 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 com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:66) Caused by: org.hotswap.agent.javassist.CannotCompileException: [source error] no such class: org.hotswap.agent.config.PluginManager at org.hotswap.agent.javassist.CtBehavior.insertAfter(CtBehavior.java:877) at org.hotswap.agent.javassist.CtBehavior.insertAfter(CtBehavior.java:792) at org.hotswap.agent.plugin.log4j2.Log4j2Plugin.registerConfigurator(Log4j2Plugin.java:128) ... 50 more Caused by: compile error: no such class: org.hotswap.agent.config.PluginManager at org.hotswap.agent.javassist.compiler.MemberResolver.searchImports(MemberResolver.java:470) at org.hotswap.agent.javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:414) at org.hotswap.agent.javassist.compiler.MemberResolver.lookupClassByJvmName(MemberResolver.java:321) at org.hotswap.agent.javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:683) at org.hotswap.agent.javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157) at org.hotswap.agent.javassist.compiler.ast.CallExpr.accept(CallExpr.java:46) at org.hotswap.agent.javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:665) at org.hotswap.agent.javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157) at org.hotswap.agent.javassist.compiler.ast.CallExpr.accept(CallExpr.java:46) at org.hotswap.agent.javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:665) at org.hotswap.agent.javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157) at org.hotswap.agent.javassist.compiler.ast.CallExpr.accept(CallExpr.java:46) at org.hotswap.agent.javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242) at org.hotswap.agent.javassist.compiler.CodeGen.atStmnt(CodeGen.java:330) at org.hotswap.agent.javassist.compiler.ast.Stmnt.accept(Stmnt.java:50) at org.hotswap.agent.javassist.compiler.Javac.compileStmnt(Javac.java:567) at org.hotswap.agent.javassist.CtBehavior.insertAfterAdvice(CtBehavior.java:899) at org.hotswap.agent.javassist.CtBehavior.insertAfter(CtBehavior.java:851) ... 52 more

is it a known issue?

skybber commented 4 years ago

It looks you are using WbSphere, it is not supported by HotswapAgent since it is closed source as I know.

omer727 commented 4 years ago

I'm using Jetty, integrated into my application

skybber commented 4 years ago

I've looked for com.hp.mqm and found some misleading connection to WebSphere. Sorry for this.

omer727 commented 4 years ago

I'm not sure about log4j specifically (I'll try it later) , but when I've disabled all the plugins everything works without any exception.

skybber commented 4 years ago

Do you know where to find sources of MqmServer.java ?

omer727 commented 4 years ago

It's our product octane, which is not open sourced. Anything you specific you want me to check on the code?

skybber commented 4 years ago

Do you have custom classloader?

omer727 commented 4 years ago

No, nothing special. It's the regular java UrlClassLoader. (you can see it as part of the stacktrace)

When my teammate used it on mac, he didn't have any issues. Did you try the agent on windows platform? When I've disabled all of the plugins, everything works. When I've disabled only log4j, I still have issues.

polyzium commented 9 months ago

Please help, I am getting the same error with PaperMC for Bukkit plugin development. I am also getting other errors while doing hotswap. Using IDEA's debugging mechanism.

/home/polyzium/Development/papermc-test/jbr-17.0.10-linux-x64-b1207.1/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:49251,suspend=y,server=n -XX:+AllowEnhancedClassRedefinition -XX:HotswapAgent=fatjar -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar=file:/tmp/capture.props -Dfile.encoding=UTF-8 -classpath /usr/share/idea/lib/idea_rt.jar -jar /home/polyzium/Development/papermc-test/paper-1.20.4-390.jar -nogui
Connected to the target VM, address: '127.0.0.1:49251', transport: 'socket'
HOTSWAP AGENT: 14:11:46.921 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent {1.4.2-SNAPSHOT} - unlimited runtime class redefinition.
HOTSWAP AGENT: 14:11:47.086 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [WatchResources, ClassInitPlugin, AnonymousClassPatch, Hotswapper, JdkPlugin, Hibernate, HibernateJakarta, Hibernate3, Hibernate3JPA, Spring, SpringBoot, Jersey1, Jersey2, Jetty, Tomcat, ZK, Logback, Log4j2, MyFaces, Mojarra, Omnifaces, ELResolver, WildFlyELResolver, OsgiEquinox, Owb, OwbJakarta, Proxy, WebObjects, Weld, WeldJakarta, JBossModules, ResteasyRegistry, Deltaspike, GlassFish, Weblogic, Vaadin, Wicket, CxfJAXRS, FreeMarker, Undertow, MyBatis, IBatis, JacksonPlugin, Idea, Thymeleaf, Velocity]
Starting HotswapAgent '/home/polyzium/Development/papermc-test/jbr-17.0.10-linux-x64-b1207.1/lib/hotswap/hotswap-agent.jar'
Starting org.bukkit.craftbukkit.Main
HOTSWAP AGENT: 14:11:47.545 ERROR (org.hotswap.agent.annotation.handler.PluginClassFileTransformer) - InvocationTargetException in transform method on plugin 'class org.hotswap.agent.plugin.log4j2.Log4j2Plugin' class 'org/apache/logging/log4j/core/LoggerContext' of classLoader 'java.net.URLClassLoader'
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.hotswap.agent.annotation.handler.PluginClassFileTransformer.transform(PluginClassFileTransformer.java:220)
    at org.hotswap.agent.annotation.handler.PluginClassFileTransformer.transform(PluginClassFileTransformer.java:112)
    at org.hotswap.agent.util.HotswapTransformer.transform(HotswapTransformer.java:264)
    at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
    at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:541)
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:375)
    at org.bukkit.craftbukkit.Main.tryPreloadClass(Main.java:382)
    at org.bukkit.craftbukkit.Main.tryPreloadClass(Main.java:378)
    at org.bukkit.craftbukkit.Main.main(Main.java:198)
    at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.hotswap.agent.javassist.CannotCompileException: [source error] no such class: org.hotswap.agent.config.PluginManager
    at org.hotswap.agent.javassist.CtBehavior.insertAfter(CtBehavior.java:909)
    at org.hotswap.agent.javassist.CtBehavior.insertAfter(CtBehavior.java:824)
    at org.hotswap.agent.plugin.log4j2.Log4j2Plugin.registerConfigurator(Log4j2Plugin.java:154)
    ... 27 more
Caused by: compile error: no such class: org.hotswap.agent.config.PluginManager
    at org.hotswap.agent.javassist.compiler.MemberResolver.searchImports(MemberResolver.java:479)
    at org.hotswap.agent.javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:422)
    at org.hotswap.agent.javassist.compiler.MemberResolver.lookupClassByJvmName(MemberResolver.java:329)
    at org.hotswap.agent.javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:711)
    at org.hotswap.agent.javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:170)
    at org.hotswap.agent.javassist.compiler.ast.CallExpr.accept(CallExpr.java:49)
    at org.hotswap.agent.javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:693)
    at org.hotswap.agent.javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:170)
    at org.hotswap.agent.javassist.compiler.ast.CallExpr.accept(CallExpr.java:49)
    at org.hotswap.agent.javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:693)
    at org.hotswap.agent.javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:170)
    at org.hotswap.agent.javassist.compiler.ast.CallExpr.accept(CallExpr.java:49)
    at org.hotswap.agent.javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:266)
    at org.hotswap.agent.javassist.compiler.CodeGen.atStmnt(CodeGen.java:360)
    at org.hotswap.agent.javassist.compiler.ast.Stmnt.accept(Stmnt.java:53)
    at org.hotswap.agent.javassist.compiler.Javac.compileStmnt(Javac.java:578)
    at org.hotswap.agent.javassist.CtBehavior.insertAfterAdvice(CtBehavior.java:931)
    at org.hotswap.agent.javassist.CtBehavior.insertAfter(CtBehavior.java:883)
    ... 29 more