org.codehaus.jackson.map.JsonMappingException: No serializer found error

4,246 views
Skip to first unread message

tao yan

unread,
Sep 21, 2012, 2:55:28 PM9/21/12
to terrastore-...@googlegroups.com
I am a new comer to the area of Terrastore, I need some help to start with it.
 
My code is simply to test read, wirte and delete a java object to Terrastore:
TerrastoreDBClient.java:

import terrastore.client.*;
import terrastore.client.connection.resteasy.HTTPConnectionFactory;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;

public class TerrastoreDBClient
{
TerrastoreClient client = null;
BucketOperation customers = null;

public void init()
{
client = new TerrastoreClient("http://localhost:8080", new HTTPConnectionFactory());      //1 master and 1 server in total
  customers = client.bucket("customers");

//disable jackson SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS
//ObjectMapper mapper = new ObjectMapper();
//mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
}

public int test()
{
Table t = new Table(4, 5);

if(customers == null)
return -1;

//create:
customers.key("t").put(t);

//Read:
Table t2 = customers.key("t").get(Table.class);


//Delete:
customers.key("t").remove();

return 0;
}

public static void main(String[] args)
{
TerrastoreDBClient client = new TerrastoreDBClient();
client.init();
client.test();
}
}
Table.java:


public class Table
{
private int x;
private int y;
public Table(int x, int y)
{
this.x = x;
this.y = y;
}
}
I created a java object of class "Table" in my code and tried to store it in Terrastore. Then it shows the error message below.
It seems to be a jackson configuration problem, i tried to disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, but it seems that jackson didn't notify that configuration.
Error message:
--------------------------------------------------------------
Exception in thread "main" terrastore.client.TerrastoreClientException: Could not service your request: java.lang.RuntimeException: org.codehaus.jackson.map.JsonMappingException: No serializer found for class Table and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )
at terrastore.client.connection.resteasy.HTTPConnection.getClientSideException(HTTPConnection.java:625)
at terrastore.client.connection.resteasy.HTTPConnection.putValue(HTTPConnection.java:192)
at terrastore.client.KeyOperation.put(KeyOperation.java:57)
at TerrastoreDBClient.test(TerrastoreDBClient.java:32)
at TerrastoreDBClient.main(TerrastoreDBClient.java:48)
Caused by: java.lang.RuntimeException: org.codehaus.jackson.map.JsonMappingException: No serializer found for class Table and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )
at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor$ClientRequestEntity.<init>(ApacheHttpClientExecutor.java:159)
at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor.loadHttpMethod(ApacheHttpClientExecutor.java:226)
at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor.execute(ApacheHttpClientExecutor.java:78)
at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)
at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)
at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)
at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)
at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)
at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:449)
at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:679)
at org.jboss.resteasy.client.ClientRequest.put(ClientRequest.java:541)
at terrastore.client.connection.resteasy.HTTPConnection.putValue(HTTPConnection.java:185)
... 3 more
Caused by: org.codehaus.jackson.map.JsonMappingException: No serializer found for class Table and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )
at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52)
at org.codehaus.jackson.map.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:25)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.java:2575)
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:2065)
at terrastore.client.mapping.JsonObjectWriter.writeTo(JsonObjectWriter.java:61)
at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:48)
at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:48)
at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
at org.jboss.resteasy.client.ClientRequest.writeRequestBody(ClientRequest.java:477)
at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor$ClientRequestEntity.<init>(ApacheHttpClientExecutor.java:154)
... 14 more

Sergio Bossa

unread,
Sep 22, 2012, 4:10:07 PM9/22/12
to terrastore-...@googlegroups.com
Hi Tao,

the Table object should provide a no-arg constructor and
setters/getters, unless you properly configure Jackson to behave
differently, in which case please refer to its documentation.

Let me know if that works for you.
Cheers,

Sergio B.
--
Sergio Bossa
http://www.linkedin.com/in/sergiob
Reply all
Reply to author
Forward
0 new messages