[mule-user] No Serializer for JSONObject

515 views
Skip to first unread message

apveitas

unread,
Feb 3, 2012, 2:48:27 PM2/3/12
to us...@mule.codehaus.org
Hi,

Am fairly new to Mule and am using Jersey module to implement a REST Service that has a method that returns a org.json.JSONObject. At runtime after the method returns, Jersey/Mule complain with the following error:

1. No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException)

Any one have any ideas on how to resolve this?

@Path("/blah")
public class BlahResource {

@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces("application/json")

public JSONObject handlePostBlah(@FormParam("x") String x) {

JSONObject jsonObject = new JSONObject();

// omit details

return jsonObject;

}
}

********************************************************************************
Message : Failed to invoke JerseyResourcesComponent{}. Component that caused exception is: JerseyResourcesComponent{}. Message payload is of type: ContentLengthInputStream
Code : MULE_ERROR--2
-----
Exception stack is:
1. No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException)
org.codehaus.jackson.map.ser.StdSerializerProvider$1:89 (null)
2. Failed to invoke JerseyResourcesComponent{platform-connector-rest-flow.commponent.32364979}. Component that caused exception is: JerseyResourcesComponent{platform-connector-rest-flow.commponent.32364979}. Message payload is of type: ContentLengthInputStream (org.mule.component.ComponentException)
org.mule.component.AbstractComponent:148 ([http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html])
-----
Root Exception stack trace:
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )
at org.codehaus.jackson.map.ser.StdSerializerProvider$1.failForEmpty(StdSerializerProvider.java:89)
at org.codehaus.jackson.map.ser.StdSerializerProvider$1.serialize(StdSerializerProvider.java:62)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:606)


Thanks,
Al

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply all
Reply to author
Forward
0 new messages