mbuhot / eskotlin

Elasticsearch Query DSL for Kotlin
MIT License
136 stars 28 forks source link

ClassNotFoundException #11

Closed kevinludwig closed 6 years ago

kevinludwig commented 6 years ago

I'm unable to use this library because of various ClassNotFoundExceptions. An example stack trace:

java.lang.ClassNotFoundException: org.elasticsearch.index.query.Operator
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_91]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_91]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_91]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_91]
    at mbuhot.eskotlin.query.fulltext.MatchKt.match(Match.kt:50) ~[eskotlin-0.3.0.jar:na]
    at com.demo.search.services.QueryBuilder.termMatch(QueryBuilder.kt:18) ~[main/:na]
    at com.demo.search.services.QueryBuilder$build$1.invoke(QueryBuilder.kt:56) ~[main/:na]
    at com.demo.search.services.QueryBuilder$build$1.invoke(QueryBuilder.kt:8) ~[main/:na]
    at mbuhot.eskotlin.query.compound.BoolKt.bool(Bool.kt:37) ~[eskotlin-0.3.0.jar:na]
    at com.demo.search.services.QueryBuilder.build(QueryBuilder.kt:53) ~[main/:na]
    at com.demo.search.services.SearchService.search(SearchService.kt:42) ~[main/:na]
    at com.demo.search.controllers.SearchController.search(SearchController.kt:23) ~[main/:na]
mbuhot commented 6 years ago

Please include the version of eskotlin and elasticsearch packages that you are using.

kevinludwig commented 6 years ago

I'm using the latest published, 0.3.0 of eskotlin. I'm using latest Elasticsearch server, however I'm using direct REST calls via Spring's RestTemplate, so the only elastic search library that I pull in is ESKotlin (which itself pulls in elasticsearch 5.0.0 I believe).

mbuhot commented 6 years ago

Looks like a classpath issue from the stacktrace.

The Operator enum definitely exists in the elasticsearch library.

Does adding an explicit dependency on elasticsearch get it working?

eg:

compile "org.elasticsearch:elasticsearch:5.0.0"
mbuhot commented 6 years ago

Closing - I don't think this is an issue in ESKotlin, but something to do with how spring boot manages the elasticsearch dependency.