我尝试使用我的GWT / Maven项目设置DCEVM(JDK 1.8 51)和HotSwap-Agent,以便能够重新加载更改而无需重新启动GWT的超级Devmode。首先,我的项目设置如下:
项目
-core
-data
-i18n
其中core是运行mvn gwt:run的主要模块。这取决于i18n和数据模块,所以我也喜欢重新加载它们。所以在我的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:运行启动开发模式。 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安装时,例如,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)时,我没有得到任何搜索结果。所以,我真的不知道发生了什么。任何帮助都会很棒!