gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 18:28:04 27 4
gpt4 key购买 nike

我有一个 sbt 项目,其中包括 elasticsearch 我正在创建我的 sbt 项目的自定义图像并使用 elasticsearch:1.6.0 公共(public)图像
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"]

这是 dockerfile elasticsearch:1.6.0 公开镜像
https://github.com/MonsantoCo/docker-elasticsearch/blob/master/1.6.0/Dockerfile

我正在像这样启动 Elasticsearch 容器

这是我运行容器的方式
docker create network mynetwork

启动 Elasticsearch 容器
docker run -p 9200:9200 -p 9300:9300 --network mynetwork elasticsearch:1.6.0

启动我的项目容器
docker run --network mynetwork myproject:v1

我收到以下异常
org.elasticsearch.common.inject.CreationException:Guice 创建错误:
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));

这是配置文件
es.clusterName="myCluster"
es.host="172.18.0.2"

我看过ip 172.18.0.2在 elasticsearch docker 容器日志中
Redneck] bound_address {inet[/0.0.0.0:9300]}, publish_address {inet[/172.18.0.2:9300]}

这里是elasticsearch容器的运行状态
293f2f750398        elasticsearch:1.6.0         "/docker-entrypoint.…"   30 seconds ago      Up 22 seconds                     0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   zealous_johnson

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

最佳答案

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

关于docker - elasticsearch-1.6 连接到其 docker 容器时无法初始化类 org.elasticsearch.monitor.jvm.JvmInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56167397/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com