Navigation Menu

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

Add support for GraalVM native images #343

Closed
gtskaushik opened this issue Aug 27, 2021 · 4 comments
Closed

Add support for GraalVM native images #343

gtskaushik opened this issue Aug 27, 2021 · 4 comments

Comments

@gtskaushik
Copy link

Hi Team
Thanks for your work on HibernateTypes. When we are trying to build a native image for Spring Boot, the build succeeds but while running, it fails with the following error:
`
Native reflection configuration for org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.getJavaType() is missing.

Action:

Native configuration for a method accessed reflectively is likely missing
`

Following are the type hints added
@NativeHint(types = { @TypeHint(types = { org.springframework.jdbc.datasource.SimpleDriverDataSource.class, com.vladmihalcea.hibernate.type.basic.PostgreSQLEnumType.class, com.vladmihalcea.hibernate.type.json.JsonBinaryType.class })

Spring Boot version - 2.5.4
Spring Native version - 0.10.3-SNAPSHOT

@vladmihalcea
Copy link
Owner

At the moment, the library does not support GraalVM. The #202 issue was created some time ago, but no one added support for it.

If you want to investigate what's needed in order to make it work on GraalVM, I'd love to integrate your contribution.

@edudar
Copy link
Contributor

edudar commented Sep 3, 2022

I've spent some time tracking this down as I faced the same issue with JSON types. So far, I think the culprit is this

Type type = (xProperty instanceof JavaXMember) ?
  ReflectionUtils.invokeGetter(xProperty, "javaType") :
  ((ParameterType) parameters.get(PARAMETER_TYPE)).getReturnedClass();

reflection call to get javaType. I don't know hibernate-types good enough, and not sure why it needs to be a reflection call here, but doing ((JavaXMember) xProperty).getJavaType(), after all, we just checked type that it's JavaXMember, allowed me to move past Hibernate issues.

@vladmihalcea, I can make a PR if this sounds like a proper fix.

@vladmihalcea
Copy link
Owner

vladmihalcea commented Sep 3, 2022

Sure thing. Please send the PR.

@vladmihalcea vladmihalcea changed the title GraalVM native image build failed in Spring when using Hibernate Types Add support for GraalVM native images Sep 5, 2022
@vladmihalcea vladmihalcea added this to the 2.19.0 milestone Sep 5, 2022
@vladmihalcea
Copy link
Owner

Fixed.

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

Successfully merging a pull request may close this issue.

3 participants