JsonMappingException on android

#1

Hi,

I am using cbl on android through Couchbase-Lite-PhoneGap-Plugin, quite many JsonMappingException errors logged, and some views can not get results.

E/View: Error emitting com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.mozilla.javascript.Undefined and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59) at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:129) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3383) at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:2777) at com.couchbase.lite.View$2.emit(View.java:499) at com.couchbase.lite.javascript.scopes.MapGlobalScope.emit(MapGlobalScope.java:26) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:476) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) at com.couchbase.lite.javascript.ViewMapBlockRhino.map(ViewMapBlockRhino.java:53) at com.couchbase.lite.View.updateIndex(View.java:621) at com.couchbase.lite.router.Router.queryDesignDoc(Router.java:1933) at com.couchbase.lite.router.Router.do_GET_DesignDocument(Router.java:1964) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.couchbase.lite.router.Router.start(Router.java:471) at com.couchbase.lite.listener.LiteServlet.service(LiteServlet.java:128) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2251) at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2176) at Acme.Serve.Serve$ServeConnection.run(Serve.java:1988) at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1223) at java.lang.Thread.run(Thread.java:841)

I also reported the issue here

Thanks!

Hanzhi

Weird, view name affect the view result!
#2

Don’t pass JavaScript “Undefined” values to the emit function. They aren’t valid JSON. You may be doing this by accident if you’re not checking that a property value exists before emitting it.

#3

Thank you jens!

I added checks in all view definitions, exceptions disappeared.