0

I'm trying to setup DCEVM (JDK 1.8 51) and HotSwap-Agent with my GWT/Maven project to be able to reload changes without restarting GWT's Super Devmode. To start with, my project is setup like so:

project
-core
-data
-i18n

where core is the main module where I run mvn gwt:run. It depends on the i18n and data modules, so I'd like those to be reloaded as well. So in my hotswap-agent.properties, I put:

extraClasspath=<pathto>/i18n/target/classes,<pathto>/data/build/target/classes

I've gotten as far as installing DCEVM as the alt jvm, and setup my MAVEN_OPTS like so:

SET MAVEN_OPTS=-XXaltjvm=dcevm -javaagent:<pathto>/hotswap-agent.jar -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic 

From here I do mvn gwt:run to start dev mode. HotSwap-Agent seems to properly initialize as evidenced by these lines:

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'.

And then devmode is started, I can run my application and all that.

Now, when I go to do a mvn clean install on data, for example, HotSwap-Agent seems to detect the changes, but this is what I get:

HOTSWAP AGENT: 11:2:38.541 WARNING (org.hotswap.agent.watch.nio.WatcherNIO2) - WatchKey 'sun.nio.fs.WindowsWatchService$WindowsWatchKey@7d9da813' overflowed

And then, a huge list of (it looks like I get a trace for every class in the module):

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

This all occurs when hotswap-agent notices a change in my core module as well.

After all that, the program resumes properly, but the changes don't take affect, even if I refresh the browser. I get no search results when I look up the overflow message or the filenotfound exceptions (in reference to hotswap-agent). So, I don't really know what's going on. Any help would be great!

Troncoso
  • 2,343
  • 3
  • 33
  • 52
  • 2
    First things first: why do you (think you) have to restart Super Dev Mode when making changes to your code? The only reason for restarting SDM is when you change the code of a GWT generator or linker, or you need to change the classpath somehow (OK, there might currently be some case where you have an annotation that references a class –e.g. `@ProxyFor`–, and that annotation is read by a GWT generator, and you currently have to have the referenced class available in the classpath) – Thomas Broyer Aug 28 '15 at 15:30
  • I *know* I have to when there are server side changes to apply. This is not for client side code. That's just how web apps work in most cases, GWT being one of them. – Troncoso Aug 28 '15 at 15:37
  • 2
    You can reload the webapp in `DevMode`, you don't have to restart `DevMode`; just like you'd redeploy webapps in most cases. – Thomas Broyer Aug 28 '15 at 18:17
  • No. Restarting super devmode code server is exactly how you reload server side changes. Since devmode is what starts the Jetty server that my app is hosted in, it is also restarted. – Troncoso Aug 28 '15 at 20:02
  • 2
    No. Clicking the "Restart Server" button in the "Jetty" tab of DevMode (or clicking the double spinning arrows button in the DevMode view when using the Eclipse integration) is how you redeploy the webapp in the embedded Jetty server. It'll appropriately call your `ServletContextListener`'s `contextDestroyed` and `contexteInitialized` (if you have any) when doing so, like when redeploying a webapp in a "real" Jetty server, or Tomcat, Glassfish, etc. – Thomas Broyer Aug 28 '15 at 22:00

0 Answers0