elasticsearch-1.6在连接到其docker容器时无法初始化org.elasticsearch.monitor.jvm.JvmInfo类

时间:2019-05-16 11:21:31

标签: docker elasticsearch elasticsearch-1.6.0

我有一个包含Elasticsearch的sbt项目,我正在为我的sbt项目创建自定义图像,并使用elasticsearch:1.6.0 public image https://hub.docker.com/_/elasticsearch

这是我的sbt项目的docker文件

FROM hseeberger/scala-sbt:11.0.2_2.12.8_1.2.8 as stripecommon

MAINTAINER sara <sarawaheed3191@gmail.com>

WORKDIR /myproject

ADD myprojectcode .

CMD ["sbt","reload","clean","compile","run"]

这是elasticsearch的{​​{1}}:1.6.0公开图片  https://github.com/MonsantoCo/docker-elasticsearch/blob/master/1.6.0/Dockerfile

我正在像这样启动Elasticsearch容器

这是我运行容器的方式

dockerfile

启动Elasticsearch容器

docker create network mynetwork

启动我的项目容器

docker run -p 9200:9200 -p 9300:9300 --network mynetwork elasticsearch:1.6.0

我遇到以下异常 org.elasticsearch.common.inject.CreationException:Guice创建错误:

docker run --network mynetwork myproject:v1

这是我的连接代码

1) Error injecting constructor, java.lang.ExceptionInInitializerError
  at org.elasticsearch.cache.recycler.PageCacheRecycler.<init>(Unknown Source)
  while locating org.elasticsearch.cache.recycler.PageCacheRecycler
    for parameter 0 at org.elasticsearch.common.util.BigArrays.<init>(Unknown Source)
  while locating org.elasticsearch.common.util.BigArrays
    for parameter 3 at org.elasticsearch.transport.netty.NettyTransport.<init>(Unknown Source)
  while locating org.elasticsearch.transport.netty.NettyTransport
  while locating org.elasticsearch.transport.Transport
    for parameter 1 at org.elasticsearch.transport.TransportService.<init>(Unknown Source)
  while locating org.elasticsearch.transport.TransportService
Caused by: java.lang.ExceptionInInitializerError
    at org.elasticsearch.common.unit.MemorySizeValue.parseBytesSizeValueOrHeapRatio(MemorySizeValue.java:42)
    at org.elasticsearch.common.settings.ImmutableSettings.getAsMemory(ImmutableSettings.java:401)
    at org.elasticsearch.cache.recycler.PageCacheRecycler.<init>(PageCacheRecycler.java:74)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.elasticsearch.common.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:54)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:86)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at org.elasticsearch.common.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at org.elasticsearch.common.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.FactoryProxy.get(FactoryProxy.java:52)
    at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
    at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:837)
    at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
    at org.elasticsearch.common.inject.Scopes$1$1.get(Scopes.java:57)
    at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
    at org.elasticsearch.common.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at org.elasticsearch.common.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
    at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:837)
    at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
    at org.elasticsearch.common.inject.Scopes$1$1.get(Scopes.java:57)
    at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
    at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:200)
    at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:193)
    at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:830)
    at org.elasticsearch.common.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:193)
    at org.elasticsearch.common.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:175)
    at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:110)
    at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
    at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
    at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:195)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:125)
    at models.ElasticSearchConnectionInfo$.createClient(ElasticSearchConnectionInfo.scala:31)
    at models.ElasticSearchConnectionInfo$.getClient(ElasticSearchConnectionInfo.scala:41)
    at esconnection.ESconnectionStart.ESconStart(ESconnectionStart.scala:9)
    at com.ifkaar.hazelcastserver.HazelcastServer.main(HazelcastServer.java:35)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at sbt.Run.invokeMain(Run.scala:98)
    at sbt.Run.run0(Run.scala:92)
    at sbt.Run.execute$1(Run.scala:68)
    at sbt.Run.$anonfun$run$4(Run.scala:80)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
    at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
    at sbt.TrapExit$App.run(TrapExit.scala:253)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.UnsupportedOperationException: Boot class path mechanism is not supported
    at java.management/sun.management.RuntimeImpl.getBootClassPath(RuntimeImpl.java:99)
    at org.elasticsearch.monitor.jvm.JvmInfo.<clinit>(JvmInfo.java:77)
    ... 60 more

2) Error injecting constructor, java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.monitor.jvm.JvmInfo
  at org.elasticsearch.cache.recycler.PageCacheRecycler.<init>(Unknown Source)
  while locating org.elasticsearch.cache.recycler.PageCacheRecycler
    for parameter 0 at org.elasticsearch.common.util.BigArrays.<init>(Unknown Source)
  while locating org.elasticsearch.common.util.BigArrays
    for parameter 3 at org.elasticsearch.transport.netty.NettyTransport.<init>(Unknown Source)
  while locating org.elasticsearch.transport.netty.NettyTransport
  while locating org.elasticsearch.transport.Transport
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.monitor.jvm.JvmInfo
    at org.elasticsearch.common.unit.MemorySizeValue.parseBytesSizeValueOrHeapRatio(MemorySizeValue.java:42)
    at org.elasticsearch.common.settings.ImmutableSettings.getAsMemory(ImmutableSettings.java:401)
    at org.elasticsearch.cache.recycler.PageCacheRecycler.<init>(PageCacheRecycler.java:74)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.elasticsearch.common.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:54)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:86)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at org.elasticsearch.common.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at org.elasticsearch.common.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
    at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
    at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)
    at org.elasticsearch.common.inject.FactoryProxy.get(FactoryProxy.java:52)
    at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
    at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:837)
    at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
    at org.elasticsearch.common.inject.Scopes$1$1.get(Scopes.java:57)
    at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
    at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:200)
    at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:193)
    at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:830)
    at org.elasticsearch.common.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:193)
    at org.elasticsearch.common.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:175)
    at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:110)
    at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
    at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
    at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:195)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:125)
    at models.ElasticSearchConnectionInfo$.createClient(ElasticSearchConnectionInfo.scala:31)
    at models.ElasticSearchConnectionInfo$.getClient(ElasticSearchConnectionInfo.scala:41)
    at esconnection.ESconnectionStart.ESconStart(ESconnectionStart.scala:9)
    at com.ifkaar.hazelcastserver.HazelcastServer.main(HazelcastServer.java:35)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at sbt.Run.invokeMain(Run.scala:98)
    at sbt.Run.run0(Run.scala:92)
    at sbt.Run.execute$1(Run.scala:68)
    at sbt.Run.$anonfun$run$4(Run.scala:80)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
    at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
    at sbt.TrapExit$App.run(TrapExit.scala:253)
    at java.base/java.lang.Thread.run(Thread.java:834)

这是配置文件

val clusterName=config.getString("es.clusterName")
   val host=config.getString("es.host")

val settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).build();
     client = new TransportClient(settings);
     client.addTransportAddress(new InetSocketTransportAddress(host,9300));

我在elasticsearch docker容器日志中看到了IP es.clusterName="myCluster" es.host="172.18.0.2"

172.18.0.2

这是elasticsearch容器的运行状态

Redneck] bound_address {inet[/0.0.0.0:9300]}, publish_address {inet[/172.18.0.2:9300]}

请在这里指导我在做什么错

1 个答案:

答案 0 :(得分:0)

似乎您正在使用jdk 11或更高版本来通过非常老的Elasticsearch客户端(1.6.0)运行应用程序。我尝试通过jdk 8使用客户端建立连接,并获得成功。我也尝试了jdk 11,并得到了相同的错误。希望对您有帮助。