elasticsearch-1.6 Could not initialize class org.elasticsearch.monitor.jvm.JvmInfo when connecting to its docker container

I have an sbt project which includes elasticsearch i am creating a custom image of my sbt project and using elasticsearch:1.6.0 public image
https://hub.docker.com/_/elasticsearch

here is the docker file of my sbt project

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

MAINTAINER sara <[email protected]>

WORKDIR /myproject

ADD myprojectcode .

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

and here is the dockerfile of the elasticsearch:1.6.0 public image
https://github.com/MonsantoCo/docker-elasticsearch/blob/master/1.6.0/Dockerfile

i am starting the elasticsearch container like this

here is how i am running my containers

docker create network mynetwork

to start elasticsearch container

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

to start my project container

docker run --network mynetwork myproject:v1

i am getting the following exceptions
org.elasticsearch.common.inject.CreationException: Guice creation errors:

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)

here is my connection code

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));

and here is the config file

es.clusterName="myCluster"
es.host="172.18.0.2"

i have seen the ip 172.18.0.2 in elasticsearch docker container logs

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

here is the running status of the elasticsearch container

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

please guide what i am doing wrong here

Source: StackOverflow