Exception when getting mapping using Java API

We're trying to get mapping for an index using Java API according to:

 final GetMappingsResponse response = esClient.admin().indices().prepareGetMappings(indexName)
                   .setTypes(indexType).execute().actionGet();

Call fails and throws following exception:

TransportSerializationException[Failed to deserialize response of type [org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse]]; nested: NoClassDefFoundError[Could not initialize class org.elasticsearch.cluster.metadata.MappingMetaData];
        org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:152)
        org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:124)
        org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
        org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
        org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
        org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
        org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
        org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
        org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
        org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
        org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
        org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
        org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
        org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
        org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
        org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
        org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
        org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
        org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
        org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
        java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        java.lang.Thread.run(Thread.java:745)
</pre></p><p><b>root cause</b> <pre>java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.cluster.metadata.MappingMetaData
        org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse.readFrom(GetMappingsResponse.java:62)
        org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:150)
        org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:124)
        org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
        org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
        org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
        org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
        org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
        org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
        org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
        org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
        org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
        org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
        org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
        org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
        org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
        org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
        org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
        org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
        org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
        org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
        java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        java.lang.Thread.run(Thread.java:745)

We're using Elastic 2.4.1. Things we have already verified according to suggestion found online:

  • JVM is same across cluster
  • Elastic client version is same as cluster version
  • Elastic dependencies are available on classpath.
1 Like

That's super strange. Are you sure you don't have different versions in your classpath?

Versions of elastic- jar? Nope. I'm certain that we only have elasticsearch-2.4.1.jar on classpath.

Are there other dependencies that we should look into?

I can add that we're doing:

 GetSettingsResponse getSettingsResponse = esClient.admin().indices().prepareGetSettings(storeName).execute()
                .actionGet();

from the same component and that works

We restarted our container running the component and tried again.

Instead of:

java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.cluster.metadata.MappingMetaData

we then got:

TransportSerializationException[Failed to deserialize response of type [org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse]]; nested: NoClassDefFoundError[com/ning/compress/lzf/util/ChunkDecoderFactory]; nested: ClassNotFoundException[com.ning.compress.lzf.util.ChunkDecoderFactory];

So problem was that "com.ning.compress.lzf.util.ChunkDecoderFactory" was missing on classpath.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.