mbreese/couchdb4j — Issue #2: json-lib needs to be upgraded to 2.4
Author: abhinavlele
Created: 2012-01-29 07:02:55+00:00
State: open

Adding a new view from code gives the following error with the older library. It works fine with 2.4 (json-lib).

Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Property 'text' has no getter method
at net.sf.json.JSONObject._fromBean(JSONObject.java:958)
at net.sf.json.JSONObject.fromObject(JSONObject.java:193)
at net.sf.json.JSONObject._processValue(JSONObject.java:2778)
at net.sf.json.JSONObject.processValue(JSONObject.java:2837)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2852)
at net.sf.json.JSONObject._accumulate(JSONObject.java:2725)
at net.sf.json.JSONObject.accumulate(JSONObject.java:1631)
at com.fourspaces.couchdb.Document.addView(Document.java:198)
at couch.Main.createViewGetSession(Main.java:37)
at couch.Main.main(Main.java:23)
Caused by: java.lang.NoSuchMethodException: Property 'text' has no getter method
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1127)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:686)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:290)
at net.sf.json.JSONObject._fromBean(JSONObject.java:930)
... 9 more

Sample Code:

Document doc = new Document();
doc.addView("checkexist", "getSessions", "function(doc) {\n emit(doc.sessionID, doc); \n}");
db.saveDocument(doc);