Hello,
I wrote a Java program which should store data in Elasticsearch. I decided to use a transport client.
When I run the programm the first time, the document is indexed:
Output:
Feb 02, 2016 4:46:49 PM org.elasticsearch.plugins.PluginsService
INFORMATION: [Man-Spider] loaded [], sites []
Name: Cluster [dman]
Document created
Index: library
Type: article
ID: AVKiqjWGpjGvtNa5kG9W
When I run this program a second time I get the following error:
"Failed to deserialize response of type".
Below the code and a part of the detailed error message.
Does somebody know why this error occurs?
import java.io.IOException;
import java.net.InetAddress;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
public class docman {
public static void main(String[] args) throws IOException {
Settings settings = Settings.settingsBuilder()
.put("cluster.name", "dman").build();
Client client = TransportClient.builder().settings(settings).build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
String json = "{" +
"\"Title\":\"Mytitle\"," +
"\"Doc\":\"Mydoc\"" +
"}";
IndexResponse iresponse = client.prepareIndex("library", "article")
.setSource(json)
.get();
String _index = iresponse.getIndex();
String _type = iresponse.getType();
String _id = iresponse.getId();
boolean created = iresponse.isCreated();
if (created == true) {
System.out.println("Document created");
System.out.println("Index: " + _index);
System.out.println("Type: " + _type);
System.out.println("ID: " + _id);
}
client.close();
}
}
Feb 02, 2016 4:51:25 PM org.elasticsearch.plugins.PluginsService
INFORMATION: [USAgent] loaded [], sites []
Exception in thread "main" TransportSerializationException[Failed to deserialize response of type [org.elasticsearch.action.admin.cluster.state.ClusterStateResponse]]; nested: NoClassDefFoundError[com/ning/compress/lzf/util/ChunkDecoderFactory]; nested: ClassNotFoundException[com.ning.compress.lzf.util.ChunkDecoderFactory];
at org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:179)