I am using ActiveMQ to run my integration tests using mvn build. My pom.xml triggers activemq first and then triggers the integration tests so that they can use the above activeMQ instance to transfer messages.
Its working correctly but does not shut down smoothly.. When the mvn build is over and all tests are successful, the build looks good. But activemq spits out the following error while shutting down :-
'[INFO] Apache ActiveMQ 5.7.0 (localhost, ID:LB3290FPF-54398-1427490319466-0:1) is shutting down
Exception in thread "ActiveMQ ShutdownHook" java.lang.NoClassDefFoundError: org/apache/activemq/transport/vm/VMTransportFactory
at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:750)
at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.java:91)
at org.apache.activemq.broker.BrokerService.containerShutdown(BrokerService.java:2303)
at org.apache.activemq.broker.BrokerService$6.run(BrokerService.java:2270)
Caused by: java.lang.ClassNotFoundException: org.apache.activemq.transport.vm.VMTransportFactory
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 4 more
[INFO] Connector tcp://localhost:61616?useJmx=true&persistent=false Stopped'
Is there a way I enable Maven to shut activeMQ smoothly without above Exceptions when the maven build finishes? Here are some associated details :-
You need to add useShutdownHook="false" to the <broker> element of the XML config. This issue occurs when ActiveMQ is embedded and not configured correctly.
Sample config:
<amq:broker useJmx="false" persistent="false" useShutdownHook="false">
...
</amq:broker>
Reference:
Similar threads:
ActiveMQ embedded broker, exception in shutdown hook
Unable to shutdown embedded activeMQ service using the built in BrokerService.stop call
Hope it helps.
You can stop the activemq instance after integration tests are done. Just add the following lines to your pom.
<execution>
<id>stop-activemq</id>
<goals>
<goal>stop</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With