Closed tylervz closed 2 years ago
Hi @tylervz. My guess is this is an issue with the activemq-broker
dependency. Could you try adding @TypeHint([org.apache.activemq.openwire.v10.MarshallerFactory])
in your project and seeing if that resolves this specific issue?
Hi @elliottpope thanks for the suggestion. I'm a beginner with Micronaut so I'm not sure which class to decorate with @TypeHint
. Because my project is a Picocli application, I added it above my main command class.
After adding the annotation @TypeHint([org.apache.activemq.openwire.v10.MarshallerFactory])
above my AmqJmsExampleCommand
class definition, I'm unable to build the project:
error: illegal start of expression
@TypeHint([org.apache.activemq.openwire.v10.MarshallerFactory])
^
For Java you need to use {org.apache.....}
instead of [...]
Thanks @ilopmar
Now I'm getting the following error when I try to build the project:
amq-jms-example/src/main/java/amq/jms/example/AmqJmsExampleCommand.java:19: error: cannot find symbol
@TypeHint({org.apache.activemq.openwire.v10.MarshallerFactory})
^
symbol: class v10
location: package org.apache.activemq.openwire
@tylervz my bad, I fired off the comment without actually writing valid Java code. The valid syntax for you is
@TypeHint({
org.apache.activemq.openwire.v10.MarshallerFactory.class
})
and yes you can place this as a class-level annotation on your AmqJmsExampleCommand
class. I'm just verifying on my machine whether this actually solves your problem, but this is what I would expect to solve the problem
Ok, sorry this was a little late but my laptop is not powerful enough to run the native image compile.
@TypeHint(
value = { org.apache.activemq.openwire.v10.MarshallerFactory.class },
accessType = AccessType.ALL_DECLARED_METHODS)
will solve you're problem. I have tested it out on my machine and everything is working perfectly. Sample log output after build/native-image/application -v
is:
08:56:43.262 [main] INFO i.m.context.env.DefaultEnvironment - Established active environments: [cli]
About to send this message to the queue: 2b2c6320-316b-4949-93b1-004a99d46b17
Queue name: example-messages
Sent message: 2b2c6320-316b-4949-93b1-004a99d46b17
@tylervz if this resolves you're issue then I can close this ticket for you.
@graemerocher if I add
@TypeHint(
value = { org.apache.activemq.openwire.v10.MarshallerFactory.class },
accessType = AccessType.ALL_DECLARED_METHODS)
to the micronaut-jms-activemq-classic
project, will all downstream projects not require this change? What I'm basically asking is whether the @TypeHint
annotations cascade through dependencies
Yes adding that to one of the classes and ensure the annotationProcessor "io.micronaut:micronaut-graal"
is present in the dependencies will result in resolving the issue and it cascading to downstream projects
Thank you, I will add this to the project close this ticket with that PR
@elliottpope sorry for my unresponsiveness; I was on vacation and just got back.
@TypeHint(
value = { org.apache.activemq.openwire.v10.MarshallerFactory.class },
accessType = AccessType.ALL_DECLARED_METHODS)
Does indeed solve my problem. Thank you!
Task List
Steps to Reproduce
In the root directory of my example project, run the following commands
docker-compose up
to run an AMQ broker../gradlew nativeImage
(in a separate terminal) to build a native image of the application../build/native-image/application -v
to run the CLI application and have it send a message to the broker.Expected Behaviour
A message should be sent to the AMQ broker. It works fine when running the application with the JVM (
java -jar build/libs/amq-jms-example-0.1-all.jar -v
), however it throws an exception when running the Native Image.Actual Behaviour
The following error stacktrace is output when
./build/native-image/application -v
is executedEnvironment Information
Example Application
https://github.com/tylervz/amq-jms-example