Archive for the ‘CouchDB’ Category

CouchDB errors on Ubuntu Lucid

Donnerstag, Oktober 21st, 2010

The simplest way to get CouchDB running on Ubuntu is to install the package from the repository using aptitude. But I decided to install CouchDB from the sources in my home directory, so that I could play with the configuration without interfering with the CouchDB that comes with the OS and might be used by other software packages. Even the installation from the souces is pretty simple, just follow one of the examples given here: http://wiki.apache.org/couchdb/Installing_on_Ubuntu .

After the installation everything looked good at first: I could start CouchDB with couchdb -b and stop it with couchdb -d. I changed the http port in the local.ini file. After that futon came up on the new address: http://localhost:5994/_utils/index.html. The creation of a new database went well and I pushed a new application, generated with couchapp, into it. So far so good. But when I tried to call my first view, curl didn’t come back because CouchDB did not answer. A look into the logfiles showed the following error:

libmozjs.so: cannot open shared object file: No such file or directory

Fortunately google found me the answer to this problem. If I had only read the whole page about installing CouchDB on Ubuntu: http://wiki.apache.org/couchdb/Installing_on_Ubuntu. There the issue is analyzed and a fix is proposed. A xulrunner configuration file must be created. When done as recommended, and after a restart of CouchDB the logfile didn’t show no errors anymore, and the request of the view brought back the expected response. Everything’s fine. Once again: RTM – read the fucking manual.

How to use couchapp with Eclipse

Dienstag, Oktober 19th, 2010

Couchapp is a simple toolkit to generate an initial web application based on CouchDB and JavaScript / JQuery. It also helps to update documents in CouchDB, which otherwise, using curl or futon, is quite painful.

Couchapp can be integrated in Eclipse in a straightforward way, so that the editors and viewers can be used to work with the CouchDB documents, and an automatic update gets triggered when a document was changed. Here is my recipe.

Create a new Eclipse workspace.

Create a new general Eclipse project in that workspace.

 

Use a terminal, go to the project directory and create the initial couchapp content:

couchapp generate <design_document>

 

Create two new variables which will be used to define the project builders:

Goto Window > Preferences > Run/Debug > String Substitution

Create a variable couchapp with the full path to the couchapp executable as value

Create a variable couch_url with the url to your couchdb database

 

Configure the couchapp push builder for the project:

Goto Project > Properties > Builders

Create a new builder

Edit the launch configuration properties:

In the Main tab enter couchapp_push as the name of the builder, select the variable ${couchapp} for the location, as working directory select ${workspace_loc:/<project_name>}, as arguments enter -v push ${workspace_loc:/<project_name>/<design_document>} ${couchdb_url}

In the tab Build Options check the option During auto builds, also specify <project_name>/<design_document> as working set of relevant resources

Click OK

 

Create a new folder docs in the project to hold the json documwnts which will be uploaded to the CouchDB.

 

Configure the couchapp push_docs builder for the project:

Goto Project > Properties > Builders

Create a new builder

Edit the launch configuration properties:

In the Main tab enter couchapp_pushdocs as the name of the builder, select the variable ${couchapp} for the location, as working directory select ${workspace_loc:/<project_name>}, as arguments enter -v pushdocs ${workspace_loc:/<project_name>/docs} ${couchdb_url}

In the tab Build Options check the option During auto builds, also specify <project_name>/docs as working set of relevant resources

Click OK

 

Associate json files to the Java Script Editor:

Goto Window > Preferences > General > Editors > File Associations

Select *.json from the File types and add the Java Script Editor as default editor.

 

Now if you change any document under the <design-document> or the docs directory, they are loaded into the CouchDB with each save .

 CouchApp in Eclipse