helidon icon indicating copy to clipboard operation
helidon copied to clipboard

EclipseLink Sample fails to run on Graal Native Image

Open lprimak opened this issue 1 year ago • 11 comments

Follow-up to #8866

Environment Details

  • Helidon Version: 4.1.0
  • Helidon SE
  • JDK version: 21.0.2-graalce
  • OS: Mac

Problem Description

Generated sample using helidon init Database example using EclipseLink

When running the executing the generated executable, the following exception appears:

% ./helidon-sample-eclipselink
2024.08.12 18:55:14 INFO io.helidon.logging.jul.JulProvider Thread[#1,main,5,main]: Logging at runtime configured using classpath: /logging.properties
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name org.eclipse.persistence.exceptions.i18n.ConversionExceptionResource, locale en_US
	at [email protected]/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2059)
	at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1697)
	at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1600)
	at [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:1283)
	at org.eclipse.persistence.exceptions.i18n.ExceptionMessageGenerator.buildMessage(ExceptionMessageGenerator.java:71)
	at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:92)
	at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:245)
	at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:251)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.preInitializeCanonicalMetamodel(EntityManagerSetupImpl.java:4299)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:381)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)
	at io.helidon.integrations.cdi.jpa.PersistenceExtension.produceEntityManagerFactory(PersistenceExtension.java:1458)
	at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$CreateCallback.create(BeanConfiguratorImpl.java:372)
	at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$ImmutableBean.create(BeanConfiguratorImpl.java:511)
	at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
	at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
	at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:679)
	at org.jboss.weld.bean.builtin.InstanceImpl.getBeanInstance(InstanceImpl.java:262)
	at org.jboss.weld.bean.builtin.InstanceImpl$InstanceImplIterator.next(InstanceImpl.java:335)
	at io.helidon.integrations.cdi.jpa.PersistenceExtension.workAroundWeldBeanMetadataCreationBug(PersistenceExtension.java:661)
	at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)
	at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
	at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
	at org.jboss.weld.injection.MethodInvocationStrategy$DefaultMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:144)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
	at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:126)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
	at jakarta.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:142)
	at org.jboss.weld.util.Observers.notify(Observers.java:166)
	at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
	at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
	at org.jboss.weld.event.EventImpl.fire(EventImpl.java:96)
	at io.helidon.microprofile.cdi.HelidonContainerImpl.doStart(HelidonContainerImpl.java:311)
	at io.helidon.common.context.Contexts.runInContext(Contexts.java:137)
	at io.helidon.microprofile.cdi.HelidonContainerImpl.start(HelidonContainerImpl.java:258)
	at io.helidon.microprofile.cdi.Main.main(Main.java:80)
	at io.helidon.microprofile.cdi.CdiStartupProvider.start(CdiStartupProvider.java:39)
	at io.helidon.Main.main(Main.java:85)
	at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
2024.08.12 18:55:14 INFO io.helidon.Main Thread[#51,helidon-shutdown-thread,5,main]: Shutdown requested by JVM shutting down
2024.08.12 18:55:14 INFO io.helidon.Main Thread[#51,helidon-shutdown-thread,5,main]: Shutdown finished

lprimak avatar Aug 13 '24 00:08 lprimak

Hello, In order to avoid wasting time in PR, testing, opening new issue process. Would you be willing to try the fix from my branch (https://github.com/tvallin/helidon/tree/4.x-native-image-eclipselink) and verify that it properly fixes your use case ?

tvallin avatar Sep 10 '24 12:09 tvallin

Hi @lprimak, Did you have a chance to try these changes out ?

tvallin avatar Oct 01 '24 09:10 tvallin

Sorry it slipped through the cracks. Thanks for the reminder!

lprimak avatar Oct 01 '24 17:10 lprimak

Tried compiling, but getting errors:

[INFO] ---------------------------------------------------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ---------------------------------------------------------------------------------------------------------------------
[INFO] Total time:  14.897 s (Wall Clock)
[INFO] Finished at: 2024-10-10T22:32:37Z
[INFO] ---------------------------------------------------------------------------------------------------------------------
[ERROR] io.helidon.build.common.RichTextProvider: Provider io.helidon.build.common.ansi.AnsiTextProvider could not be instantiated: org/fusesource/jansi/AnsiConsole: org.fusesource.jansi.AnsiConsole -> [Help 1]
[ERROR] java.util.ServiceConfigurationError: io.helidon.build.common.RichTextProvider: Provider io.helidon.build.common.ansi.AnsiTextProvider could not be instantiated: org/fusesource/jansi/AnsiConsole: org.fusesource.jansi.AnsiConsole
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the '-e' switch
[ERROR] Re-run Maven using the '-X' switch to enable verbose output
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ServiceConfigurationError

Maybe too much of a lift to compile the whole of Helidon. Maybe if you can provide a compiled binary please?

Thank you!

lprimak avatar Oct 10 '24 22:10 lprimak

NVM I got it to compile. Needed an Intel / Ubuntu / JDK 21 / maven 3 container which I had to build :)

lprimak avatar Oct 11 '24 00:10 lprimak

Great news! I was able to test the sample and it works with your branch. Have not tried it yet with Postgres, which is the next step

lprimak avatar Oct 11 '24 00:10 lprimak

Sounds good ! I guess you are referring to the issue you opened about hibernate and PostgreSQL .. I have another branch for that here: https://github.com/tvallin/helidon/tree/4.x-native-image-hibernate

tvallin avatar Oct 11 '24 13:10 tvallin

Awesome. I'll try this one. Im running into another issue with EclipseLink (not a Helidon issue at all) EL doesn't work in a multi-module project with weaving limitations, as Hibernate does. Probably Hibernate will be the only option for me.

lprimak avatar Oct 11 '24 16:10 lprimak

Tried https://github.com/tvallin/helidon/tree/4.x-native-image-hibernate However, got the following error. Not sure how / if that relates, but I can't get passed this...

[WARNING] [stderr] Error: Classes that should be initialized at run time got initialized during image building:
[WARNING] [stderr]  org.eclipse.yasson.internal.JsonbContext was unintentionally initialized at build time. To see why org.eclipse.yasson.internal.JsonbContext got initialized use --trace-class-initialization=org.eclipse.yasson.internal.JsonbContext
[WARNING] [stderr] To see how the classes got initialized, use --trace-class-initialization=org.eclipse.yasson.internal.JsonbContext

lprimak avatar Oct 11 '24 17:10 lprimak

More info:

[WARNING] [stderr] Error: Classes that should be initialized at run time got initialized during image building:
[WARNING] [stderr]  org.eclipse.yasson.internal.JsonbContext was unintentionally initialized at build time. org.hibernate.type.format.jakartajson.JakartaJsonIntegration caused initialization of this class with the following trace: 
[WARNING] [stderr] 	at org.eclipse.yasson.internal.JsonbContext.<clinit>(JsonbContext.java:45)
[WARNING] [stderr] 	at org.eclipse.yasson.internal.JsonBinding.<init>(JsonBinding.java:45)
[WARNING] [stderr] 	at org.eclipse.yasson.internal.JsonBindingBuilder.build(JsonBindingBuilder.java:61)
[WARNING] [stderr] 	at jakarta.json.bind.JsonbBuilder.create(JsonbBuilder.java:86)
[WARNING] [stderr] 	at org.hibernate.type.format.jakartajson.JsonBJsonFormatMapper.<init>(JsonBJsonFormatMapper.java:27)
[WARNING] [stderr] 	at org.hibernate.type.format.jakartajson.JakartaJsonIntegration.<clinit>(JakartaJsonIntegration.java:16)
[WARNING] [stderr] 
[WARNING] [stderr] 

lprimak avatar Oct 11 '24 18:10 lprimak

Passed this error. I can now confirm that the branch fixes the EclipseLink issue. Thank you!

lprimak avatar Oct 11 '24 22:10 lprimak