So I searched for a Grails plugin and found a 2 years old one: Grom-CouchDB.
Installing the plugin wasn't easy. I first tried my Grails 2.0.x installation - it easily picks up the plugin, but when I try to run it, I get a strange compilation error:
user@ubuntu:~/grails/couch3$ grails run-app | Compiling 53 source files. | Error Compilation error: startup failed: Compile error during compilation with javac. /home/user/.grails/2.0.4/projects/couch3/plugins/gorm-couchdb-0.9.2/ src/java/org/codehaus/groovy/grails/plugins/couchdb/domain /CouchDomainClass.java:49: error: CouchDomainClass is not abstract and does not override abstract method getPersistentProperty(String) in GrailsDomainClass public class CouchDomainClass extends AbstractGrailsClass implements ExternalGrailsDomainClass { ^ /home/user/.grails/2.0.4/projects/couch3/plugins/gorm-couchdb-0.9.2/ src/java/org/codehaus/groovy/grails/plugins/couchdb/domain /CouchDomainClassProperty.java:37: error: CouchDomainClassProperty is not abstract and does not override abstract method isDerived() in GrailsDomainClassProperty public class CouchDomainClassProperty implements GrailsDomainClassProperty { ^ Note: /home/user/.grails/2.0.4/projects/couch3/plugins/ gorm-couchdb-0.9.2/src/java/org/codehaus/groovy/grails/plugins/ couchdb/domain/CouchDomainClass.java uses or overrides a deprecated API.
Not a good start. Especially when I can't imagine that Grails 1.3.x should not bring up the same exception. Nevertheless, I'll give it a try.
Somehow, I really ran into problem when I even just tried to install the plugin with Grails 1.3.x. The plugin is in the list when I do a <pre>grails install-plugin gorm-couchdb</pre> but when the script runs, it tells me that it can't find the plugin.
So I tried to download and install it but I've got the same result. So I made use of my last special trick: I copied and renamed the downloaded zip:
cp gorm-couchdb-0.9.2.zip grails-gorm-couchdb-0.9.2.zipand tried to install it:
grails install-plugin grails-gorm-couchdb-0.9.2.zipIt is very interesting, that if you try to install it with the grails-prefix, it seems to pick up the file without the prefix. But it does not work the other way around. Another interesting thing is that I only ran into this problem on my linux machine. Netbeans managed to install it without any problem. I guess that this is fixed in Grails 2.0.x
Ok. So now, we have an installed plugin. If you read through the documentation, you'll find that you don't have to remove the hibernate plugin. Even better, you can configure that plugin to use anotation in order to mix hibernate and couchDB. But beware: if you want to make use of
grails generate-all domainYou first have to execute this script and only afterwards anotate your domain class - otherwise it will tell you that it can't map your domain:
Running script /usr/share/grails/1.3.8/scripts/GenerateAll.groovy Environment set to development Domain class not found in grails-app/domain, trying hibernate mapped classes... No domain class found for name sevendatabases.DataTypes. Please try again and enter a valid domain class name Application context shutting down... Application context shutdown.By working around this, I managed to setup my test project, but unfortunately, as soon as I try to access the list controller, I get the following Exception:
org.jcouchdb.exception.DataAccessException: error querying view: code 404 at org.jcouchdb.db.Database.queryViewInternal(Database.java:848) at org.jcouchdb.db.Database.queryView(Database.java:656) at org.jcouchdb.db.Database$queryView.call(Unknown Source) at org.jcouchdb.db.Database$queryView.call(Unknown Source) at sevendatabases.DataTypesController$_closure2.doCall(DataTypesController.groovy:13) at sevendatabases.DataTypesController$_closure2.doCall(DataTypesController.groovy) at java.lang.Thread.run(Thread.java:722)So, that's it for now. I guess this problem is beacuse I use the current version of CouchDB, but it makes no sense for me to downgrade to a 2 year old version just to make the plugin work.
For me, CouchDB seems to be great, but there is no easy way to use it with a standard Grails CRUD application... :-(
No comments:
Post a Comment