vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
864 stars 58 forks source link

[BUG] NPE in Hilla engine when accidentally trying to start project that has been built for production #2591

Open mvysny opened 3 days ago

mvysny commented 3 days ago

Description of the Bug

I built the app using mvn -C clean package -Pproduction, then I tried to run it in my IDE to continue development. A silly mistake on my side, sure, but Hilla could be more forgiving than throwing

Caused by: java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.resolve(String)" because "configDir" is null
    at com.vaadin.hilla.engine.EngineConfiguration.loadDirectory(EngineConfiguration.java:54)

Expected Behavior

Hilla could print "Rebuild the app in dev mode" or similar.

Minimal Reproducible Example

  1. Open the skeleton-starter-flow-spring project in Intellij
  2. Build it in production mode: mvn -C clean package -Pproduction
  3. Run it in dev mode from IDEA: run Application.main(), with hotswap agent enabled as per Copilot's instructions (the hotswap fat jar enabled etc)

The following exception is thrown, preventing Copilot from starting:

HOTSWAP AGENT: 09:47:50.539 ERROR (org.hotswap.agent.command.ReflectionCommand) - Error executin method onHotswap in class com.vaadin.hilla.Hotswapper
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    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.command.impl.CommandExecutor.run(CommandExecutor.java:43)
Caused by: java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.resolve(String)" because "configDir" is null
    at com.vaadin.hilla.engine.EngineConfiguration.loadDirectory(EngineConfiguration.java:54)
    at com.vaadin.hilla.OpenAPIUtil.getCurrentOpenAPIPath(OpenAPIUtil.java:65)
    at com.vaadin.hilla.EndpointCodeGenerator.getClassesUsedInOpenApi(EndpointCodeGenerator.java:127)
    at com.vaadin.hilla.Hotswapper.affectsEndpoints(Hotswapper.java:106)
    at com.vaadin.hilla.Hotswapper.onHotswap(Hotswapper.java:39)
    ... 6 more

Versions

Artur- commented 3 days ago

Is this a Hilla problem or is there any connection to Copilot?

mvysny commented 3 days ago

Could be pure Hilla problem; I saw Hotswap Agent in the stacktrace and immediately made a (maybe premature) connection to Copilot. Feel free to move the ticket to Hilla github repo if needed.