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

Missing native image hints for JDK proxies created by JMS connection factories #33590

Closed
krezovic opened this issue Sep 24, 2024 · 2 comments
Closed
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@krezovic
Copy link

Affects: v6.2.0-RC1

Classes (may be incomplete, but these two were sufficient for working send/receive example via JMS queue)

  • org.springframework.jms.connection.SingleConnectionFactory
  • org.springframework.jms.connection.CachingConnectionFactory

use JDK proxies to obtain jakarta.jms.Connection and org.springframework.jms.connection.SessionProxy, among others, but there are no native image hints, so any attempt to send/receive a JMS message in native-image will fail with exceptions similar to one below

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access the proxy class inheriting [org.springframework.jms.connection.SessionProxy, jakarta.jms.QueueSession, jakarta.jms.TopicSession] without it being registered for runtime reflection. Add [org.springframework.jms.connection.SessionProxy, jakarta.jms.QueueSession, jakarta.jms.TopicSession] to the dynamic-proxy metadata to solve this problem. Note: The order of interfaces used to create proxies matters. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#dynamic-proxy for help.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forProxy(MissingReflectionRegistrationUtils.java:89)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:176)
        at [email protected]/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:47)
        at [email protected]/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1034)
        at org.springframework.jms.connection.CachingConnectionFactory.getCachedSessionProxy(CachingConnectionFactory.java:289)
        at org.springframework.jms.connection.CachingConnectionFactory.getSession(CachingConnectionFactory.java:267)
        at org.springframework.jms.connection.SingleConnectionFactory$SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:741)

I was able to capture and create proxy-config.json using graalvm native agent but as far as I know, native image hints are provided by META-INF/spring/aot.factories and/or org.springframework.aot.hint.RuntimeHintsRegistrar

Please find a reproducer here: https://github.com/krezovic/artemis-native-demo - branch "bugreport" ... "main" branch contains the proxy hints file

Run it with:

./start-artemis-docker.sh
./mvnw clean package -P native
./mvnw native:compile-no-fork
./target/artemis-native-demo

If adding of native image hints is responsibility of spring-boot, then please let me know and I will move the issue accordingly.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 24, 2024
@sbrannen sbrannen added in: messaging Issues in messaging modules (jms, messaging) theme: aot An issue related to Ahead-of-time processing labels Sep 27, 2024
@sbrannen sbrannen changed the title [JMS]: Missing native image hints for JDK proxies in Single,CachingConnectionFactory Missing native image hints for JDK proxies created by JMS connection factories Sep 27, 2024
@bclozel bclozel self-assigned this Oct 9, 2024
@bclozel bclozel added this to the 6.1.14 milestone Oct 14, 2024
@bclozel bclozel added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 14, 2024
@bclozel
Copy link
Member

bclozel commented Oct 14, 2024

Thanks for the report @krezovic !
The proxies hints will be generated as of now. I see that you're running with many other hints for the artemis library. You might want to contribute those to the library directly or in the reachability metadata repository for better integration maybe?

@krezovic
Copy link
Author

Thanks for the fix.

I tried contributing the hints file, but I can't get used to gradle build they use so I got lost and simply dropped it. Plus, I use docker for hints file generation and testing and they have tedious docker image approval process that I don't really want to go through.

Not sure how I would go using artemis-jakarta-server via TCP/Netty/whatever ... I tried with spring.artemis.mode=embedded and I didn't get the right hints for spring.artemis.mode=native ... as expected.

If anyone wants to contribute the data back to them, you are welcome and have my permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants