Márton Sereg
Márton Sereg

Reputation: 283

Executable jar built with spring-boot gradle-plugin missing dependency

I have an executable JAR that I've built with Spring Boot's Gradle plugin. It has the following dependencies in the build file:

build.gradle

compile('org.apache.activemq:activemq-client:5.9.0')
compile('org.apache.activemq:activemq-broker:5.9.0')
compile('org.apache.activemq:activemq-kahadb-store:5.9.0')
compile('org.apache.activemq.protobuf:activemq-protobuf:1.1')

The problem is that after I run ./gradlew clean build the created artifact does not contain the activemq-protobuf jar, only the other activemq jars:

[] jar -tf build/libs/application-0.1.0.jar | grep activemq
lib/activemq-client-5.9.0.jar
lib/activemq-broker-5.9.0.jar
lib/activemq-kahadb-store-5.9.0.jar
lib/activemq-openwire-legacy-5.9.0.jar

So when I try to run the jar, I got an Exception that a class from this dependency cannot be found:

java.lang.ClassNotFoundException: org.apache.activemq.protobuf.Message

During the build the dependency gets downloaded and it can be found in my gradle cache, it seems that for some reason Spring Boot's Gradle plugin doesn't include it during the bootRepackage task.

This dependency is also there in Eclipse, and the project can be run from there.

Any ideas about why it gets missing?

Upvotes: 5

Views: 2822

Answers (2)

vamsi-vegi
vamsi-vegi

Reputation: 305

the following is a quick fix, while the bug is resolved. try this in your gradle.build file

jar {
baseName = 'gs-accessing-data-rest'
version = '0.1.0'
into('lib') {
    from 'oraDrv'
   }

}

where oraDrv is a folder in which you have your custom jars or the missing jars. it is assumed that the oraDrv is relative the build.gradle file location.

Upvotes: 0

Andy Wilkinson
Andy Wilkinson

Reputation: 116261

This looks like a bug in Spring Boot. I've opened an issue so that we can investigate. Thanks for bringing it to our attention.

Upvotes: 1

Related Questions