views:

709

answers:

4

I have a Grails app that loads its data from xml files and delivers rss feeds via rome. I don't have any domain classes and my app has no datasource. I don't want Grails to load an in memory hsql db when the application has no need for it. Deleting the DataSource.groovy file prevents me from launching the web app, it seems as though the datasource is required, but is there anything I can do if my application doesn't need a datasource?

+2  A: 

The in-memory database is very lightweight so you should stick with that if you don't need a real database.

Burt Beckwith
We've run into a similar problem. Deploying more then one grails app on the same tomcat instance with the default datasource settings does not work. I believe this is because the hSQL instances use the same on disk lock files or something.
Gennadiy
Yeah, the default production datasource uses an hql file datastore. You can't use the same file name for more than 1 grails app, so you need to change the database name in the datasource. It's pretty annoying. Being able to just not have a datasource would still be preferable. Even if it's lightweight, if you're not going to use it why have it there.
Jack Chu
A: 

Then why on earth are you running it in Grails? The stack IS wonderful, but it's massive. And it sounds to me that it's totally unnecessary for your application. I mean, that's the point of using an ORM-enabled framework in the first place. Just build a groovy script if you need it that badly. Or write a super simple php parser with CoreyLib (http://coreylib.com). Takes two minutes. Problem solved.

Kenneth Reitz
The view and controller part are useful with out needing a model. If you want to write a web app in groovy grails is the only way to do it unless you want to write your own framework or use only gsp. This is also not a real answer since it doesn't address the actual question.
Jared
In my case, this is an existing app that needs to be maintained. I can't just pick another framework. Our server infrastructure is setup for Java or Grails, I can't just any technology I want. I do think using just the controller/view layers in grails is reasonable. Sitemesh, GSP, tag lib support, testing, controllers, groovy,etc all work pretty well.
Jack Chu
+1  A: 

I was able to comment out the data source and get a default grails app to run. Comment out your production section in the same way I commented out the following code in datasource.groovy


/*  development {
     dataSource {
      dbCreate = "create-drop" // one of 'create', 'create-drop','update'
      url = "jdbc:hsqldb:mem:devDB"
     }
    }*/

I was also able to remove the hibernate plugin using "grails uninstall-plugin hibernate" and still have the default app run. I haven't done extensive testing with this but hopefully this works for you.

Jared
+4  A: 

The following steps work for a new app (Grails 1.1.1) to run without using a datasource:

grails create-app nodb
cd nodb
grails uninstall-plugin hibernate
rm grails-app/conf/DataSource.groovy
grails create-controller Foo
<add "render "hi bar" to the index closure of ./grails-app/controllers/FooController.groovy>
grails run-app
http://localhost:8080/nodb/foo - prints hi bar

For an existing app on at least version 1.1 (think that's when hibernate was made a plugin) you should be able to just uninstall-plugin and delete the DataSource.groovy file.

John Wagenleitner