Skip to content

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

@krezovic

Description

@krezovic

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.

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)theme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions