I hope title itself is descriptive but to be clear I am trying to include one of the jar
(ie, error-handling-service.jar) in greeting-service.jar. After build I included greeting-service.jar in new project(ie,TestApplication) but on executing the TestApplication I am getting(BTW, TestApplication is not a gradle project)
Exception in thread "main" java.lang.NoClassDefFoundError: co/common/exception/BaseException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
co.common.exception.BaseException is a class in error-handling-service module
As per question here. I included
manifest {
attributes(
"Manifest-Version": "1.0",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
Here is build.gradle of greeting-service which is dependent on error-handling service
buildscript {
repositories {
mavenCentral()
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile('org.apache.commons:commons-lang3:3.0')
compile('org.apache.commons:commons-collections4:4.0')
compile('org.slf4j:slf4j-api:1.7.25')
compile('co.common:error-handling-service:1.0.0-SNAPSHOT')
testCompile("org.mockito:mockito-all:1.9.5")
testCompile('junit:junit:4.12')
}
jar {
baseName = 'greeting-service'
version = '1.0.0-SNAPSHOT'
manifest {
attributes(
"Manifest-Version": "1.0",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
group = 'co.common'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
After successful build of greeting-service, I included greeting-service.jar in TestApplication and still I received the same exception mentioned above.
Manifest-Version: 1.0
Class-Path: commons-lang3-3.0.jar commons-io-2.4.jar commons-collections
4-4.0.jar slf4j-api-1.7.25.jar error-handling-service-1.0.0-SNAPSHOT.
jar commons-logging-1.1.3.jar
Why is this happening and what should be done ?