Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java live-reload with HotSwap agent is semi-working #19247

Open
mshabarov opened this issue Apr 25, 2024 · 2 comments
Open

Java live-reload with HotSwap agent is semi-working #19247

mshabarov opened this issue Apr 25, 2024 · 2 comments

Comments

@mshabarov
Copy link
Contributor

Description of the bug

HotSwap agent live-reload works unstable - works only for first reload on some machines, somewhere it works without issues.

For testing results on Mac, see my comments here and here.

Windows:
Hotswap state is shown correctly on the info Window. 24.3.10 and snapshot initial compile and reload passes fine, but does not refresh the client. There is a new Java live reload available: HotswapAgent info on the debug window.
After the initial reload further reloads get an exception:

HOTSWAP AGENT: 09:39:12.302 WARNING (org.hotswap.agent.plugin.vaadin.VaadinIntegration) - Unable to obtain ApplicationRouteRegistry instance; routes are not updated:
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.plugin.vaadin.VaadinIntegration.updateRoutes(VaadinIntegration.java:81)
    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.command.ReflectionCommand.doExecuteReflectionCommand(ReflectionCommand.java:207)
    at org.hotswap.agent.command.ReflectionCommand.executeCommand(ReflectionCommand.java:168)
    at org.hotswap.agent.plugin.vaadin.VaadinPlugin$UpdateRoutesCommand.executeCommand(VaadinPlugin.java:165)
    at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:43)
Caused by: java.lang.ClassCastException: Cannot cast com.vaadin.flow.server.startup.ApplicationRouteRegistry$ApplicationRouteRegistryWrapper to com.vaadin.flow.server.startup.ApplicationRouteRegistry$ApplicationRouteRegistryWrapper
    at java.base/java.lang.Class.cast(Class.java:3889)
    at com.vaadin.flow.server.VaadinServletContext.getAttribute(VaadinServletContext.java:76)
    at com.vaadin.flow.server.VaadinContext.getAttribute(VaadinContext.java:58)
    at com.vaadin.flow.server.startup.ApplicationRouteRegistry.getInstance(ApplicationRouteRegistry.java:112)
    ... 13 more

The server mostly survives and reloads correctly after, but the client doesn't reload.
At times the server dies on the second reload with:

jakarta.servlet.ServletException: java.lang.reflect.InvocationTargetException
    at com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer.lambda$onStartup$2 (ClassLoaderAwareServletContainerInitializer.java:103)
    at com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer.onStartup (ClassLoaderAwareServletContainerInitializer.java:122)
    at org.eclipse.jetty.servlet.ServletContainerInitializerHolder.doStart (ServletContainerInitializerHolder.java:148)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:93)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:171)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    ...
Caused by: java.lang.ClassCastException: Cannot cast com.vaadin.flow.server.startup.DeferredServletContextInitializers to com.vaadin.flow.server.startup.DeferredServletContextInitializers
    at java.lang.Class.cast (Class.java:3889)
    at com.vaadin.flow.server.VaadinServletContext.getAttribute (VaadinServletContext.java:76)
    at com.vaadin.flow.server.VaadinContext.getAttribute (VaadinContext.java:58)
    at com.vaadin.flow.server.startup.LookupServletContainerInitializer.lambda$process$0 (LookupServletContainerInitializer.java:110)
    at com.vaadin.flow.di.LookupInitializer.initialize (LookupInitializer.java:283)

and it doesn't seem to get back up even with consecutive class reloads/rebuilds.

Expected behavior

Live-reload works without exceptions.

Minimal reproducible example

Test with the steps described in this ticket, the same instructions basically as described in the Vaadin online docs.

Versions

  • Vaadin / Flow version: latest versions of 24.3 and 24.4
  • Java version: JBR 17.0.10
  • OS version: Mac, Windows
  • Browser version (if applicable): Chrome
  • Application Server (if applicable): Jetty
  • IDE (if applicable): IDEA
@jorgheymans
Copy link

jorgheymans commented May 2, 2024

I have observed this as well lately, the browser "sometimes" no longer refreshes after a recompile of a class is triggered in Intellij. (this is on Ubuntu LTS, latest Vaadin 24.3)

@echarlus
Copy link

echarlus commented May 7, 2024

Hi, I'm also experiencing this issue on mac (aarch64) with latest Hotswap version and Vaadin 23.4.x (currently 24.3.10)
See my post here
Hotswap seems to works randomly ...

@mshabarov mshabarov self-assigned this May 8, 2024
@mshabarov mshabarov removed their assignment May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 High Priority (P1)
Status: 🟢Ready to Go
Development

No branches or pull requests

3 participants