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

Native build troubles with Copilot and Hilla @Menu #5270

Open
deniz-frick opened this issue Apr 25, 2024 · 2 comments
Open

Native build troubles with Copilot and Hilla @Menu #5270

deniz-frick opened this issue Apr 25, 2024 · 2 comments
Labels

Comments

@deniz-frick
Copy link

deniz-frick commented Apr 25, 2024

Describe the bug

vaadin-copilot is in the classpath even when the production classpath is used.

After creating a native build as described in the vaadin docs (mvn -Pproduction -Pnative native:compile), missing reflection configuration and copilot being on the classpath causes an exception in SpringBridge.call.

This can be prevented by excluding vaadin copilot in the production profile as per the edit in this gist. The gist also contains the logfiles with complete stacktraces.

After doing this and building another native build, this also fails with the following exception:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of 'com.vaadin.hilla.route.records.ClientViewConfig': cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
 at [Source: (ByteArrayInputStream); line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
	at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1915) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:414) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1355) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1431) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:359) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825) ~[my-app.exe:2.15.4]
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3817) ~[my-app.exe:2.15.4]
	at com.vaadin.hilla.route.ClientRouteRegistry.registerClientRoutes(ClientRouteRegistry.java:158) ~[my-app.exe:na]
	at com.vaadin.hilla.startup.RouteUnifyingServiceInitListener.serviceInit(RouteUnifyingServiceInitListener.java:89) ~[my-app.exe:na]
	at com.vaadin.flow.server.VaadinService.lambda$init$0(VaadinService.java:236) ~[my-app.exe:24.4.0.alpha30]

So hilla is missing reflection information that is essential for graalvm native builds to work as intended.

Expected-behavior

Native builds should work without issue if no external dependencies are used.

I also encountered issues with hibernate-spatial and native builds but that is of course not caused by vaadin.

Reproduction

  1. Download this starter app with flow and hilla views.
  2. Run the application once normally (sping-boot:run) to check if everything is working.
  3. Create a production build.
  4. Run it and see it fail (this causes log1.txt - see gist)
  5. Change the pom.xml (add an exclusion for vaadin-copilot in the production profile - see gist)
  6. Add a @Menu() annotation to EmptyView
  7. Add vaadin.expose-server-routes-to-client=true to the application.properties file to enable @Menu
  8. Run it again normally to see both views in the side navigation
  9. Create a production build.
  10. Run it an see it fail (log2.txt in the gist)

System Info

JDK (output of java --version):
java 21.0.3 2024-04-16 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37, mixed mode, sharing)

Vaadin:
24.4.0.alpha23

OS:
Windows 11 Pro Version 23H2 (Build 22631.3447)

@Artur-
Copy link
Member

Artur- commented Apr 25, 2024

It looks like the project is missing the exclusion of development only artifacts from the production build. Try adding this to the pom.xml https://github.com/vaadin/skeleton-starter-hilla-react/pull/219/files

@deniz-frick
Copy link
Author

@Artur- I had a similar fix in place but the second issue with ClientViewConfig is unaffected by this.
Your change fixes the first issue though. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants