Reputation: 42340
I am building a SpringBoot REST client that hooks into a CorDapp (Corda Application) via RPC. The RPC proxy has a dependency on ActiveMQ/Artemis.
My gradle.build file contains these dependencies
compile "org.apache.activemq:artemis-commons:$active_mq_version"
compile "org.apache.activemq:artemis-core-client:$active_mq_version"
When I run the application from IntelliJ, everything works fine.
The module and all its dependencies are Fat-JAR'd into a stand-alone JAR file using the following gradle task
jar {
zip64 = true
from {
String[] include = [
"kotlin-runtime-${kotlin_version}.jar",
"kotlin-stdlib-${kotlin_version}.jar"
]
configurations.compile
.findAll { include.contains(it.name) }
.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.client.ApplicationKt'
)
}
}
When I try to run the JAR file, I get the following exception:
java.lang.NoSuchMethodError: org.apache.activemq.artemis.api.core.client.ClientSession.createTemporaryQueue(Lorg/apache/activemq/artemis/api/core/SimpleString;Lorg/apache/activemq/artemis/api/core/RoutingType;Lorg/apache/activemq/artemis/api/core/SimpleString;)
When I inspect the contents of the JAR file, it appears that ActiveMQ/Artemis has been Fat-JAR'd correctly, so I'm not sure why it can't find the method?
Upvotes: 1
Views: 994
Reputation: 6006
You don't have to create a fat jar like that when working with spring boot.
You can include the spring-boot-gradle-plugin
dependency to your build.gradle.
Then, simply running a gradle build will generate a spring boot jar file in the target
folder which will have all required dependencies and can be run with a java -jar
.
More Info here: https://spring.io/guides/gs/spring-boot/#_jar_support_and_groovy_support
Upvotes: 1