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

Generated launch code does not work (with hibernate) #2462

Closed
mwiesiolek opened this issue Aug 23, 2023 · 3 comments
Closed

Generated launch code does not work (with hibernate) #2462

mwiesiolek opened this issue Aug 23, 2023 · 3 comments

Comments

@mwiesiolek
Copy link

mwiesiolek commented Aug 23, 2023

Expected Behavior

native run works, application starts

I've noticed that adding two entries to hibernate.properties file in resources folder:
hibernate.bytecode.provider=none hibernate.bytecode.use_reflection_optimizer=false

fix the problem

Actual Behaviour

I got error as shown down below:

Error starting Micronaut server: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type [org.hibernate.SessionFactory] Message: No classes have been predefined during the image build to load from bytecodes at runtime. Path Taken: SessionFactoryPerDataSourceFactory.buildHibernateSessionFactoryBuilder(SessionFactoryBuilder sessionFactoryBuilder) --> SessionFactoryPerDataSourceFactory.buildHibernateSessionFactoryBuilder([SessionFactoryBuilder sessionFactoryBuilder])

Steps To Reproduce

  1. Download launch code: https://micronaut.io/launch?type=DEFAULT&name=demo&package=com.example&javaVersion=JDK_17&lang=JAVA&build=GRADLE&test=JUNIT&features=postgres&features=data-jpa&features=flyway&features=hibernate-jpa&version=4.0.4
  2. Execute ./gradlew nativeRun

Environment Information

MacBook Pro / macOS Ventura 13.5

java --version
openjdk 17.0.5 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

Example Application

https://micronaut.io/launch?type=DEFAULT&name=demo&package=com.example&javaVersion=JDK_17&lang=JAVA&build=GRADLE&test=JUNIT&features=postgres&features=data-jpa&features=flyway&features=hibernate-jpa&version=4.0.4

Version

4.0.4

@radovanradic
Copy link
Contributor

@mwiesiolek Please try adding this to the properties file
jpa.default.compile-time-hibernate-proxies=true and also annotate entities with @GenerateProxy
It is documented here https://micronaut-projects.github.io/micronaut-sql/latest/guide/#hibernate-proxies

@mwiesiolek
Copy link
Author

Hey @radovanradic ,

thanks for that, it helped. I would though, still expect freshly auto-generated code from https://micronaut.io/launch to at least compile if none changes have been applied.

@radovanradic
Copy link
Contributor

It compiles, just for native compile needs that one change that is documented. Launcher that creates code doesn't know it will need native so I guess it's reasonable that is not configured by default.

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

No branches or pull requests

2 participants