问题
I have been developing custom plugin for HotSwapAgent, but encountered weird issue with classloader missing plugin class.
This is the exception thrown by
####<Feb 9, 2015 12:45:54 AM PST> <Notice> <Stdout> <testbox.mycompany> <AdminServer> <Thread-87> <<WLS Kernel>> <> <> <1423471554463> <BEA-000000> <HOTSWAP AGENT: 0:45:54.463 ERROR (org.hotswap.agent.config.PluginRegistry) - Error in plugin initial processing for plugin package 'mycompany.infrastructure.hotswap.agent'
java.lang.ClassNotFoundException: mycompany.infrastructure.hotswap.agent.HotSwapMyCompanyPlugin
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.hotswap.agent.config.PluginRegistry.scanPlugins(PluginRegistry.java:89)
at org.hotswap.agent.config.PluginConfiguration.initPluginPackage(PluginConfiguration.java:120)
at org.hotswap.agent.config.PluginConfiguration.init(PluginConfiguration.java:109)
at org.hotswap.agent.config.PluginConfiguration.<init>(PluginConfiguration.java:97)
at org.hotswap.agent.config.PluginManager.initClassLoader(PluginManager.java:154)
at org.hotswap.agent.util.HotswapTransformer$1.executeCommand(HotswapTransformer.java:163)
at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:25)>
This is my hotswap-agent.properties file
pluginPackages=mycompany.infrastructure.hotswap.agent
autoHotswap=false
LOGGER=info
It seems that hotswap-agent.jar agent is properly loaded, fetches hotswap-agent.properties, but fails to load the plugin class.
I am suspecting that there is a problem with classloader hierarchy, because agent tries to load plugin class managed from WLS classloader. I am not sure what to do with that. Any ideas?
I am using WLS appserver.
回答1:
It seems that plugins have to be embeded within hotswap-plugin.jar
Linked github issue describes this problem https://github.com/HotswapProjects/HotswapAgent/issues/67
来源:https://stackoverflow.com/questions/28405905/hotswapagent-plugin-plugin-class-not-found