我正在尝试使用我的 GWT/Maven 项目设置 DCEVM (JDK 1.8 51) 和 HotSwap-Agent,以便能够在不重新启动 GWT 的 Super Devmode 的情况下重新加载更改。首先,我的项目设置如下:
项目-核心
-
数据
-i18n
其中 core 是我运行 mvn gwt:run 的主要模块。这取决于 i18n 和 data 模块,所以我也希望重新加载这些模块。所以在我的 hotswap-agent.properties 中,我放了:
extraClasspath=<pathto>/i18n/target/classes,<pathto>/data/build/target/classes
我已经将 DCEVM 安装为 alt jvm,并像这样设置我的 MAVEN_OPTS:
SET MAVEN_OPTS=-XXaltjvm=dcevm -javaagent:<pathto>/hotswap-agent.jar -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic
从这里我做 mvn gwt:run 来启动开发模式。HotSwap-Agent 似乎已正确初始化,如下所示:
HOTSWAP AGENT: 10:43:6.444 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent {0.3.0-SNAPSHOT} - unlimited runtime class redefinition.
HOTSWAP AGENT: 10:43:6.663 INFO (org.hotswap.agent.config.PluginRegistry) - Discovered plugins: [Hotswapper, WatchResources, AnonymousClassPatch, Hibernate, Spring, Jersey2, Jetty, Tomcat, ZK, Logback, JSF, Seam, ELResolver, OsgiEquinox, Proxy, WebObjects, Weld]
HOTSWAP AGENT: 11:17:46.400 INFO (org.hotswap.agent.config.PluginRegistry) - Plugin 'org.hotswap.agent.plugin.hotswapper.HotswapperPlugin' initialized in ClassLoader 'java.net.URLClassLoader@4d49f239'.
然后 devmode 启动,我可以运行我的应用程序和所有这些。
现在,例如,当我对数据进行 mvn clean install 时,HotSwap-Agent 似乎检测到了更改,但这就是我得到的:
HOTSWAP AGENT: 11:2:38.541 WARNING (org.hotswap.agent.watch.nio.WatcherNIO2) - WatchKey 'sun.nio.fs.WindowsWatchService$WindowsWatchKey@7d9da813' overflowed
然后,一个巨大的列表(看起来我得到了模块中每个类的跟踪):
HOTSWAP AGENT: 11:2:43.945 ERROR (org.hotswap.agent.annotation.handler.WatchEventCommand) - Unable create CtClass for URI 'file:///<pathto>/data/build/target/classes/<packageto>/DashboardWidget$DashboardWidgetMetaData.class'.
java.lang.IllegalArgumentException: java.io.FileNotFoundException: <pathto>\data\build\target\classes\<packageto>\DashboardWidget$DashboardWidgetMetaData.class (The system cannot find the file specified)
at org.hotswap.agent.util.IOUtils.toByteArray(IOUtils.java:50)
at org.hotswap.agent.annotation.handler.WatchEventCommand.createCtClass(WatchEventCommand.java:191)
at org.hotswap.agent.annotation.handler.WatchEventCommand.onWatchEvent(WatchEventCommand.java:120)
at org.hotswap.agent.annotation.handler.WatchEventCommand.executeCommand(WatchEventCommand.java:51)
at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:25)
Caused by: java.io.FileNotFoundException: <pathto>\data\build\target\classes\<packageto>\DashboardWidget$DashboardWidgetMetaData.class (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at java.net.URL.openStream(URL.java:1038)
at org.hotswap.agent.util.IOUtils.toByteArray(IOUtils.java:44)
... 4 more
HOTSWAP AGENT: 11:2:43.945 ERROR (org.hotswap.agent.annotation.handler.WatchEventCommand) - Unable create CtClass for URI 'file:///<pathto>/data/build/target/classes/<packageto>/ItemImage.class'.
java.lang.IllegalArgumentException: java.io.FileNotFoundException: <pathto>\data\build\target\classes\<packageto>\ItemImage.class (The system cannot find the file specified)
at org.hotswap.agent.util.IOUtils.toByteArray(IOUtils.java:50)
at org.hotswap.agent.annotation.handler.WatchEventCommand.createCtClass(WatchEventCommand.java:191)
at org.hotswap.agent.annotation.handler.WatchEventCommand.onWatchEvent(WatchEventCommand.java:120)
at org.hotswap.agent.annotation.handler.WatchEventCommand.executeCommand(WatchEventCommand.java:51)
at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:25)
Caused by: java.io.FileNotFoundException: <pathto>\data\build\target\classes\<packageto>\ItemImage.class (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at java.net.URL.openStream(URL.java:1038)
at org.hotswap.agent.util.IOUtils.toByteArray(IOUtils.java:44)
... 4 more
当 hotswap-agent 也注意到我的核心模块发生变化时,这一切都会发生。
毕竟,程序可以正常恢复,但更改不会生效,即使我刷新浏览器也是如此。当我查找溢出消息或 filenotfound 异常(参考 hotswap-agent)时,我没有得到任何搜索结果。所以,我真的不知道发生了什么。任何帮助都会很棒!