Hi all, I'm trying to make a secure java client for ES 5.0, but I'm met with the following error. Any ideas?
Here is my code
It's weird because it passes the type checker.
Hi all, I'm trying to make a secure java client for ES 5.0, but I'm met with the following error. Any ideas?
Here is my code
It's weird because it passes the type checker.
Please don't post pictures of text, they are difficult to read and some people may not be even able to see them.
The exception, in text:
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.VerifyError: class org.elasticsearch.xpack.XPackPlugin overrides final method onModule.(Lorg/elasticsearch/action/ActionModule;)V]]
at play.api.Application$class.handleError(Application.scala:296)
at play.api.DefaultApplication.handleError(Application.scala:402)
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205)
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
Caused by: java.lang.RuntimeException: java.lang.VerifyError: class org.elasticsearch.xpack.XPackPlugin overrides final method onModule.(Lorg/elasticsearch/action/ActionModule;)V
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523)
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130)
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129)
Caused by: java.lang.VerifyError: class org.elasticsearch.xpack.XPackPlugin overrides final method onModule.(Lorg/elasticsearch/action/ActionModule;)V
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
The code excerpt, in text:
package controllers
import java.net.InetAddress
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.common.transport.InetSocketTransportAddress
import org.elasticsearch.transport.client.PreBuiltTransportClient
import org.elasticsearch.xpack.XPackPlugin
import play.api.libs.json.Json
import play.api.mvc.Action
import play.api.mvc.Results._
import util.AWSInstance
object ElasticController {
def getClient(instanceId: String, clusterName: String = "my-cluster"): TransportClient = {
val instanceIp = AWSInstance.getInstanceById(instanceId).getPrivateIpAddress
val clientSettings = Settings.builder().put("cluster.name", clusterName).build()
new PreBuiltTransportClient(
clientSettings,
classOf[XPackPlugin]
).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(instanceIp), 9300))
}
def getIndices(instanceId: String) = Action {
Ok(
Json.toJson {
getClient(instanceId).admin().cluster().prepareState().execute().actionGet().getState.getMetaData.getConcreteAllIndices
}
)
}
}
Can you check what version of xpack you are pulling in? This looks like you have an old version of xpack with a 5.0 version of transport client.
Hi @rjernst, thanks for your reply.
Here is my build.sbt
file:
resolvers += "elasticsearch-releases" at "https://maven.elasticsearch.org/releases"
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.9.8",
"com.jcraft" % "jsch" % "0.1.53",
"org.elasticsearch.plugin" % "x-pack" % "5.0.0-alpha4",
"org.elasticsearch.client" % "transport" % "5.0.0-alpha5"
)
I'm unable to pull in 5.0.0-alpha5
of Xpack due to a build issue: Can't get 5.0.0-alpha5 from Maven
@robert-blankenship Sorry for the delayed response on this. Mixing version of the transport client and x-pack will definitely cause issues like you see. The packaging issue you linked to has been fixed in 5.0.0-beta1. In fact, there is now a prebuilt xpack transport client which you can have as a single dependency. Take a look at org.elasticsearch.client:x-pack-transport:5.0.0-beta1
. Also, note that the location of the elastic hosted maven repository has changed to https://artifacts.elastic.co/maven
.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.