Views not working on CBL/ForestDB on Android

Some background, I’m evaluating CBL for a new mobile app and ran into some trouble with ForestDB. First of all, I should say that encryption is a must for us so ForestDB was our first look. We’re also using React-Native (so the REST API). I’ve modified react-native-couchbase-lite bindings to allow me to create an encrypted ForestDB (here: Disregarding encryption for the moment (since it’s not implemented in the REST API yet).

I added some basic data with _bulkDocs and verified that the data exists in the database. I did the same for a design document. When I queried the view, I got no results. The exact same code produced results when I switched off the ForestDB flag. There are several layers of projects on Github so I’m not sure which is the right one to file a bug under. Can someone guide me?


1 Like

Hi, I am using react-native couchbase-lite too(by using this Component),and I am using forestdb as storageType(by changing the code of startCBLite() metohd). My view works fine.

Awesome! I was hoping for something that exposed the Java API rather than the REST API. Thanks. I’ll look at this.

The code to using forestdb haven’t push to github.I just hard code to using forestdb as storeType.

What’s better about this approach is that I can use encryption as well (since it uses the native API). I know how to add it, I’ll probably fork the Upinion version though since it has iOS as well.

ok, I can share my code If you need.

It’s always nice to see other code. Maybe I’ll learn something.


Do you have sample code for Database Encryption on forestDB (android)?

found it.

Example code here:

Thank you.I will try.

I’m getting this error. I think this was my original problem.

I/Database( 8842): Invalid filename as a view store: filename=db.forest.0 I/Database( 8842): Invalid filename as a view store: filename=db.forest.meta I/Database( 8842): Invalid filename as a view store: filename=attachments V/View ( 8842): twistle/conversations has no map block; skipping it E/View ( 8842): Error in obj -> json E/View ( 8842): 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) ) E/View ( 8842): at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty( E/View ( 8842): at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize( E/View ( 8842): at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue( E/View ( 8842): at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue( E/View ( 8842): at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsBytes( E/View ( 8842): at$1.emit( E/View ( 8842): at com.couchbase.lite.javascript.scopes.MapGlobalScope.emit( E/View ( 8842): at java.lang.reflect.Method.invoke(Native Method) E/View ( 8842): at java.lang.reflect.Method.invoke( E/View ( 8842): at org.mozilla.javascript.MemberBox.invoke( E/View ( 8842): at E/View ( 8842): at org.mozilla.javascript.Interpreter.interpretLoop( E/View ( 8842): at org.mozilla.javascript.Interpreter.interpret( E/View ( 8842): at E/View ( 8842): at org.mozilla.javascript.ContextFactory.doTopCall( E/View ( 8842): at org.mozilla.javascript.ScriptRuntime.doTopCall( E/View ( 8842): at E/View ( 8842): at E/View ( 8842): at E/View ( 8842): at E/View ( 8842): at com.couchbase.lite.View.updateIndexes( E/View ( 8842): at com.couchbase.lite.View.updateIndex( E/View ( 8842): at com.couchbase.lite.router.Router.queryDesignDoc( E/View ( 8842): at com.couchbase.lite.router.Router.do_GET_DesignDocument( E/View ( 8842): at java.lang.reflect.Method.invoke(Native Method) E/View ( 8842): at java.lang.reflect.Method.invoke( E/View ( 8842): at com.couchbase.lite.router.Router.start( E/View ( 8842): at com.couchbase.lite.listener.LiteServlet.service( E/View ( 8842): at javax.servlet.http.HttpServlet.service( E/View ( 8842): at Acme.Serve.Serve$ServeConnection.runServlet( E/View ( 8842): at Acme.Serve.Serve$ServeConnection.parseRequest( E/View ( 8842): at Acme.Serve.Serve$ E/View ( 8842): at Acme.Utils$ThreadPool$ E/View ( 8842): at

This is the problem:

JsonMappingException: No serializer found for class org.mozilla.javascript.Undefined

Sounds like you emitted a JavaScript Undefined object as a key or value, or as part of one, and the Jackson library can’t serialize that to JSON (since Undefined is not the same as null.)

Since you don’t get this with a SQLite database, I’m guessing that the Java implementation’s SQLite storage code has a workaround for this, probably converting the Undefined to a null, but the ForestDB storage code doesn’t have the same workaround. (@hideki would know for sure.)

The workaround would be to avoid letting Undefined values be passed to emit() and use null instead.

It seems javascript’s undefined is mapped to[ Undfined class] ( Then this class is not serializable by Jackson. JavaScript map function should not emit undefined as @jens wrote in previous comment. Or couchbase-lite-java-javascript should ignore emit with undefined or automatically convert to null.