« Return to Thread: question about H2, Tomcat, JNDI and JRuby

Re: question about H2, Tomcat, JNDI and JRuby (example given)

by cdwillie76 :: Rate this Message:

Reply to Author | View in Thread

I was able to get my JRuby on Rails application working with H2 using a JNDI database pool.  I am using JRuby 1.1RC3 with warbler 0.9.4 with the 1.1RC3 complete and goldspike 1.6 jars with tomcat 5.5.26.  The primary reason I had to do this was because tomcat on windows was giving me errors saying multiple processes were trying to access the database.  On UNIX (Linux and Solaris), this didn't happen.

The following is what I added to the conf/context.xml in my tomcat install.

<Resource
      name="h2/maadn_production"
      type="javax.sql.DataSource"
      url="jdbc:h2:/home/Chris/projects/h2_databases/maadn_production"
      driverClassName="org.h2.Driver"
      username=""
      password=""
      maxActive="100"
      maxIdle="20"/>

I also had to add the h2 jar to the common/lib.

Here is what my database.yml looked like

production:
  adapter: jdbch2
  jndi: java:h2/maadn_production

Thanks
Chris


Just a quick bump on this topic since I think I am having the same problem but with Embedded derby.  Can you please post your tomcat JNDI settings?  I didn't see anything on the Wiki yet.

Thanks!
Chris

Stephen Bannasch-3 wrote:
Hi Frank,

At 9:25 AM -0700 3/12/08, Frank LeHouillier wrote:
>Using a JNDI DataSource works great, thanks.  I will
>try to add what I've learned to the wiki soon.

I have exactly this problem -- multiple instances of my RoR webapp need access to the H2 database.

Did you add any documentation to the wiki. If you don't have time can you send me any info about how you did it and I'll add to the wiki after I get it working.

I discovered a problem that might only occur using JRuby-Rack -- I had to specify the full path to the database like this in config/database.yml:

production:
  adapter: jdbch2
  database: <%= RAILS_ROOT %>/db/sds_h2_database

see:

http://www.nabble.com/problem-accessing-H2-db-in-tomcat%2C-w-warble-war-and-jruby-rack-td16136614.html#a16136614

for more details.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: question about H2, Tomcat, JNDI and JRuby