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

Using JpaRepository causes error in native code #19683

Closed
wabrit opened this issue Aug 26, 2021 · 5 comments
Closed

Using JpaRepository causes error in native code #19683

wabrit opened this issue Aug 26, 2021 · 5 comments
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.

Comments

@wabrit
Copy link

wabrit commented Aug 26, 2021

Describe the bug

Using the spring-data-jpa extension, it is possible to use JpaRepository in JVM builds. But in native builds there is a runtime error caused by missing methods from the interface.

For example with the repository definition

public interface ErewhonRepository implements JpaRepository<Erewhon, Long> { }

and injection of this interface into an application-scoped bean, then when running native the following error is reported:

java.lang.IllegalArgumentException: Cannot find method save[class Erewhon] on class ErewhonRepository_8003579965ca368f2bc90fccf68a67bef90d72b8Impl
    at io.quarkus.arc.impl.Reflections.findMethodInternal(Reflections.java:110)
    at io.quarkus.arc.impl.Reflections$2.apply(Reflections.java:40)
    at io.quarkus.arc.impl.Reflections$2.apply(Reflections.java:37)
    at io.quarkus.arc.impl.ComputingCache$1.get(ComputingCache.java:52)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
    at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
    at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:49)
    at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:40)
    at io.quarkus.arc.impl.Reflections.findMethod(Reflections.java:81)
        at ErewhonRepository_8003579965ca368f2bc90fccf68a67bef90d72b8Impl_Subclass.<init>(ErehwonRepository_8003579965ca368f2bc90fccf68a67bef90d72b8Impl_Subclass.zig:79)

Attaching @RegisterForReflection to the interface itself, or any of those in the inheritance hierarchy, does not appear to cure the issue.

Expected behavior

It should be possible to use JpaRepository in native as well as JVM quarkus applications.

Actual behavior

A java.lang.IllegalArgumentException: Cannot find method error is raised (see details above).

How to Reproduce?

Steps to reproduce the behaviour:

  1. A minimal quarkus app with e.g. one REST entry point P.
  2. An interface I derived from JpaRepository<E, Long> based on a simple entity E (could use h2 or other in-memory DB for convenience)
  3. Make P call a method of an injected I (the actual method probably doesn't matter, it's just a trigger for Arc to go do work)

If built for JVM the call will succeed, but when run native there will be a java.lang.IllegalArgumentException: Cannot find method error when the endpoint P is hit.

Output of uname -a or ver

MINGW64_NT-10.0-18363 LAP1453 3.0.7-338.x86_64 2019-04-30 21:52 UTC x86_64 Msys

Output of java -version

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05, mixed mode, sharing)

GraalVM version (if different from Java)

OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05)

Quarkus version or git rev

2.1.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

Switching from JpaRepository to PanacheRepository makes the issue go away.

@wabrit wabrit added the kind/bug Something isn't working label Aug 26, 2021
@geoand geoand added area/spring Issues relating to the Spring integration and removed triage/needs-triage labels Aug 26, 2021
@geoand
Copy link
Contributor

geoand commented Aug 26, 2021

I was not able to reproduce this.

Please attach a reproducer project when you get a chance so we can see exactly what's going on.

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Aug 26, 2021
@wabrit
Copy link
Author

wabrit commented Aug 26, 2021

Apologies - will put something together.

@wabrit
Copy link
Author

wabrit commented Aug 28, 2021

Sorry for the delay - the simple reproducer I had hoped to put together does not reproduce the issue, so there's obviously something a little more subtle going on which will take some time to replicate.

@geoand
Copy link
Contributor

geoand commented Aug 28, 2021

Not a problem at all.

@geoand
Copy link
Contributor

geoand commented Jan 24, 2022

Closing as we did not get a reproducer

@geoand geoand closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Projects
None yet
Development

No branches or pull requests

2 participants