4

My project contains a Hibernate dependency. Just want to compile it with GraalVM. Actually, the compilation went well. But on runtime I have this.

2023-10-26 | 19:13:52.154 [        main] ←[34mINFO ←[0;39m | ←[36m                org.hibernate.Version←[0;39m | HHH000412: Hibernate ORM core version 5.6.14.Final
Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: No classes have been predefined during the image build to load from bytecodes at runtime.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:121)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.throwNoBytecodeClasses(PredefinedClassesSupport.java:76)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.loadClass(PredefinedClassesSupport.java:130)
        at [email protected]/java.lang.ClassLoader.defineClass(ClassLoader.java:280)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader.invoker(JavaDispatcher.java:1383)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$InvokerCreationAction.run(JavaDispatcher.java:459)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$InvokerCreationAction.run(JavaDispatcher.java:452)
       

I tied almost everything, the last step, I updated the hibernate version to one of the GraalVM-library-list screenshot of the compatible libs

I played around with the native-agent to capture all required proxy-classes without success. Also heard about Quarkus-Framework which integrates and optimizes a lot for GraalVM but this is out-of-scope for me.

--> Has anyone ever managed to get Hibernate running in a native compilation with GraalVM?

Additionaly: I tried hibernate-entitymanager:5.4.10 instead (each time I collected the config files with the native-agent), this leads to

Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
        at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
        at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
        at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:181)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:305)

==> UPDATE!!!<==

  • I updated all to the current Hibernate, which was a hassle due to obsolete Criteria-usages, anyhow it worked.

enter image description here

Hibernate has a transitive dependency to byte-buddy, which kills me currently related to the native compilation (@Rafael Winterhalter sorry :-) )

  • I tried the experimental feature experimental-class-define-support to get all the necessary information for predefined classes, included it with the -H:PredefinedClassesConfigurationFiles definition.

BUT always still:

Caused by: java.lang.UnsupportedOperationException: Defining new classes at runtime is not supported
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unimplemented(VMError.java:195)
        at [email protected]/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:45)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)
        at net.bytebuddy.utility.Invoker$Dispatcher.invoke(Unknown Source)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForNonStaticMethod.invoke(JavaDispatcher.java:1032)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1162)
        at jdk.proxy4/jdk.proxy4.$Proxy63.defineClass(Unknown Source)
        at net.bytebuddy.dynamic.loading.ClassInjector$UsingLookup.injectRaw(ClassInjector.java:1638)
        ... 36 more 

Has somebody a running sample with byte-buddy (in combination with hibernate) and graalvm compilation?

--> I added a little reproducer here: https://github.com/tonyre/HibernateSampleGraalVM

4
  • 1
    there is hibernate-graalvm package which is used by quarkus and springboot you can try. Commented Oct 26, 2023 at 19:02
  • 1
    Thank @ozkanpakdil you for your answer thats a good advice - I need to migrate to Hibernate 6 first, we are still using a very old one even with proprietary "Criteria" dependencies. ok, journey goes on... Commented Oct 27, 2023 at 10:40
  • hey, have you any progress or workaround for that? I have same issue right now, and yours exceptions are closest to mine. Commented Aug 29, 2024 at 20:51
  • Unfortunately not - Project on hold Commented Sep 9, 2024 at 9:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.