# Transport client indexes only the first document - fails with next ones

**URL:** <https://discuss.elastic.co/t/transport-client-indexes-only-the-first-document-fails-with-next-ones/40755>\
**Category:** Elasticsearch\
**Created:** [February 2, 2016, 3:58pm UTC](https://discuss.elastic.co/t/transport-client-indexes-only-the-first-document-fails-with-next-ones/40755 "2016-02-02T15:58:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinG](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MartinG](https://discuss.elastic.co/u/MartinG)\
**Post date:** [February 2, 2016, 3:58pm UTC](https://discuss.elastic.co/t/transport-client-indexes-only-the-first-document-fails-with-next-ones/40755/1 "2016-02-02T15:58:36Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [February 2, 2016, 4:16pm UTC](https://discuss.elastic.co/t/transport-client-indexes-only-the-first-document-fails-with-next-ones/40755/2 "2016-02-02T16:16:35Z")

</div>

You have to add the lzf jar to the class path. Check Elastisearch pom.xml for required dependencies.

```auto
         <dependency>
                <groupId>com.ning</groupId>
                <artifactId>compress-lzf</artifactId>
                <version>1.0.2</version>
            </dependency>

```

---

<div class="post-metadata">

**Author:** ![MartinG](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MartinG](https://discuss.elastic.co/u/MartinG)\
**Post date:** [February 2, 2016, 4:32pm UTC](https://discuss.elastic.co/t/transport-client-indexes-only-the-first-document-fails-with-next-ones/40755/3 "2016-02-02T16:32:39Z")

</div>

Great! This simple action solved the problem.

Thanks a lot! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:19pm UTC](https://discuss.elastic.co/t/transport-client-indexes-only-the-first-document-fails-with-next-ones/40755/4 "2017-07-05T23:19:34Z")

</div>


