I am getting a class not found exception for a local jar file I add to my project using Gradle.
So here are more details:
Using mvn command to install the jar to local repo:
mvn install:install-file -Dfile=/Users/prime/Downloads/AdAuthenticationService.jar -DgroupId=com.xxx.service -DartifactId=AdAuthenticationService -Dversion=1.0 -Dpackaging=jar
I can now verify the file is in my .m2 repo:
In my build gradle:
repositories {
jcenter()
mavenLocal()
maven {
url "https://artifacts.elastic.co/maven"
}
}
dependencies {
compile ("com.xxx.service:AdAuthenticationService:1.0")
}
Now I list all my Gradle dependencies (Runtime) using
gradle dependencies --configuration runtime
And below is the result:
=======================================
Elasticsearch Build Hamster says Hello!
=======================================
Gradle Version : 3.3
OS Info : Mac OS X 10.12.5 (x86_64)
JDK Version : Oracle Corporation 1.8.0_111 [Java HotSpot(TM) 64-Bit Server VM 25.111-b14]
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
Incremental java compilation is an incubating feature.
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
runtime - Runtime dependencies for source set 'main'.
+--- com.xxx.service:AdAuthenticationService:1.0
+--- org.elasticsearch:elasticsearch:5.5.1
| +--- org.apache.lucene:lucene-core:6.6.0
| +--- org.apache.lucene:lucene-analyzers-common:6.6.0
| +--- org.apache.lucene:lucene-backward-codecs:6.6.0
| +--- org.apache.lucene:lucene-grouping:6.6.0
| +--- org.apache.lucene:lucene-highlighter:6.6.0
| +--- org.apache.lucene:lucene-join:6.6.0
| +--- org.apache.lucene:lucene-memory:6.6.0
| +--- org.apache.lucene:lucene-misc:6.6.0
| +--- org.apache.lucene:lucene-queries:6.6.0
| +--- org.apache.lucene:lucene-queryparser:6.6.0
| +--- org.apache.lucene:lucene-sandbox:6.6.0
| +--- org.apache.lucene:lucene-spatial:6.6.0
| +--- org.apache.lucene:lucene-spatial-extras:6.6.0
| +--- org.apache.lucene:lucene-spatial3d:6.6.0
| +--- org.apache.lucene:lucene-suggest:6.6.0
| +--- org.elasticsearch:securesm:1.1
| +--- net.sf.jopt-simple:jopt-simple:5.0.2
| +--- com.carrotsearch:hppc:0.7.1
| +--- joda-time:joda-time:2.9.5
| +--- org.yaml:snakeyaml:1.15
| +--- com.fasterxml.jackson.core:jackson-core:2.8.6
| +--- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.8.6
| +--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.8.6
| +--- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.8.6
| +--- com.tdunning:t-digest:3.0
| +--- org.hdrhistogram:HdrHistogram:2.1.9
| +--- org.apache.logging.log4j:log4j-api:2.8.2
| \--- org.elasticsearch:jna:4.4.0
+--- org.elasticsearch.plugin:x-pack-api:5.5.1
| +--- org.elasticsearch.plugin:transport-netty3-client:5.5.1
| | \--- io.netty:netty:3.10.6.Final
| +--- org.elasticsearch.plugin:transport-netty4-client:5.5.1
| | +--- io.netty:netty-buffer:4.1.11.Final
| | +--- io.netty:netty-codec:4.1.11.Final
| | +--- io.netty:netty-codec-http:4.1.11.Final
| | +--- io.netty:netty-common:4.1.11.Final
| | +--- io.netty:netty-handler:4.1.11.Final
| | +--- io.netty:netty-resolver:4.1.11.Final
| | \--- io.netty:netty-transport:4.1.11.Final
| +--- com.unboundid:unboundid-ldapsdk:3.2.0
| +--- org.bouncycastle:bcprov-jdk15on:1.55
| +--- org.bouncycastle:bcpkix-jdk15on:1.55
| +--- com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:r239
| +--- com.google.guava:guava:16.0.1
| +--- com.sun.mail:javax.mail:1.5.3
| +--- javax.activation:activation:1.1
| +--- org.elasticsearch.client:rest:5.5.1
| | +--- org.apache.httpcomponents:httpclient:4.5.2
| | +--- org.apache.httpcomponents:httpcore:4.4.5
| | +--- org.apache.httpcomponents:httpasyncclient:4.1.2
| | +--- org.apache.httpcomponents:httpcore-nio:4.4.5
| | +--- commons-codec:commons-codec:1.10
| | \--- commons-logging:commons-logging:1.1.3
| +--- org.elasticsearch.client:sniffer:5.5.1
| | +--- org.elasticsearch.client:rest:5.5.1 (*)
| | +--- org.apache.httpcomponents:httpclient:4.5.2
| | +--- org.apache.httpcomponents:httpcore:4.4.5
| | +--- commons-codec:commons-codec:1.10
| | +--- commons-logging:commons-logging:1.1.3
| | \--- com.fasterxml.jackson.core:jackson-core:2.8.6
| \--- net.sf.supercsv:super-csv:2.4.0
\--- org.elasticsearch:jna:4.4.0
(*) - dependencies omitted (listed previously)
BUILD SUCCESSFUL
I can see the dependency in question listed at top of the above list. However when I deploy and run the program I get a class not found exception:
Caused by: java.lang.ClassNotFoundException: com.xxx.service.delegate.ADAuthenticationDelegate
I have the x-pack custom security module as my base code, which is on elastic github page!
Not sure what do I miss here?
Also in elasticsearch documentation I read:
Note that only jar files in the elasticsearch directory are added to the classpath for the plugin! If you need other resources, package them into a resources jar.
However the meaning of resources jar is not completely clear to me!