See reproducer: https://github.com/krezovic/artemis-native-demo
./mvnw clean package -P native
./mvnw native:compile-no-fork
target/artemis-native-demo
Results in
Caused by: java.lang.NoSuchMethodException: org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.<init>(java.lang.String)
at java.base@21.0.4/java.lang.Class.checkMethod(DynamicHub.java:1078)
at java.base@21.0.4/java.lang.Class.getConstructor0(DynamicHub.java:1241)
at java.base@21.0.4/java.lang.Class.getConstructor(DynamicHub.java:2442)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.newNativeConnectionFactory(ArtemisConnectionFactoryFactory.java:146)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.createNativeConnectionFactory(ArtemisConnectionFactoryFactory.java:134)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.doCreateConnectionFactory(ArtemisConnectionFactoryFactory.java:95)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.createConnectionFactory(ArtemisConnectionFactoryFactory.java:67)
Short guess, reflection hints are missing for factory creation.
Comment From: philwebb
I think we either need a hint or we need to change ArtemisConnectionFactoryFactory.createConnectionFactory(...) to take a Function<String,ActiveMQConnectionFactory>.
Comment From: wilkinsona
We can (and will) fix the problem caused by Boot's use of reflection, but please note that you'll then hit a problem within Artemis' code and its use of bean utils:
Caused by: java.lang.IllegalStateException: java.lang.ExceptionInInitializerError
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:239)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.newNativeConnectionFactory(ArtemisConnectionFactoryFactory.java:147)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.createNativeConnectionFactory(ArtemisConnectionFactoryFactory.java:135)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.doCreateConnectionFactory(ArtemisConnectionFactoryFactory.java:97)
at org.springframework.boot.autoconfigure.jms.artemis.ArtemisConnectionFactoryFactory.createConnectionFactory(ArtemisConnectionFactoryFactory.java:68)
... 140 more
Caused by: java.lang.ExceptionInInitializerError
at org.apache.activemq.artemis.uri.schema.connector.TCPTransportConfigurationSchema.getTransportConfigurations(TCPTransportConfigurationSchema.java:65)
at org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema.internalNewObject(TCPServerLocatorSchema.java:42)
at org.apache.activemq.artemis.uri.schema.serverLocator.TCPServerLocatorSchema.internalNewObject(TCPServerLocatorSchema.java:33)
at org.apache.activemq.artemis.utils.uri.URISchema.newObject(URISchema.java:84)
at org.apache.activemq.artemis.utils.uri.URISchema.newObject(URISchema.java:28)
at org.apache.activemq.artemis.utils.uri.URIFactory.newObject(URIFactory.java:59)
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.newLocator(ServerLocatorImpl.java:360)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.setBrokerURL(ActiveMQConnectionFactory.java:257)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:237)
... 144 more
Caused by: java.lang.IllegalArgumentException: Class java.util.Date[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.arrayHubErrorStub(SubstrateAllocationSnippets.java:351)
at org.apache.commons.beanutils.ConvertUtilsBean.registerArrayConverter(ConvertUtilsBean.java:796)
at org.apache.commons.beanutils.ConvertUtilsBean.registerArrays(ConvertUtilsBean.java:774)
at org.apache.commons.beanutils.ConvertUtilsBean.deregister(ConvertUtilsBean.java:603)
at org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:161)
at org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:113)
at org.apache.activemq.artemis.utils.uri.BeanSupport.<clinit>(BeanSupport.java:37)
... 153 more
This will have to be addressed in one of Artemis, some reachability metadata, or some reflection hints of your own.
Comment From: krezovic
This seems to be the first issue on Google when searching for Artemis, Spring and native-image so I'll just leave a comment that I have updated to latest snapshot of spring-boot 3.4, generated metadata for artemis using native agent and the application now works as expected.
The changes were added as a separate commit in the repo provided in the original comment.
Thanks for the prompt fix from spring boot side.