db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <mdegg...@gmail.com>
Subject Re: Loading derby.war (derby servlet server) before other web applications in Tomcat
Date Tue, 26 Jul 2011 16:31:54 GMT
On Tue, 26 Jul 2011 10:49:47 -0400, adam_gent-zF7ou3TX9xLSUeElwK9/Pw

> I'm trying to figure out how to use derby.war in the same
> Servlet Container as other web applications that depend on it.
> I asked the question fist on Stackoverflow (I didn't realize you had an
> active mailing list... apologies). I
> need the derby war to load first otherwise our database connection pool
> will try to immediately connect to the derby environment and fail. We
> have tried to set Spring and our db pool (bonecp) to lazy initialize but
> that doesn't seem to work correctly. Have others had this issue?
> We were hoping to have a single tomcat instance with everything you
> needed to easy installation of our
> product.

Apologies for editing your post. I stripped out the html.

I just tried a quick application on Tomcat 5.5.33, and things worked as 
expected. Here are a few thoughts.

As far as I know, servlet containers do not enforce startup order for web 
applications. This has been mentioned a couple of times on the Tomcat 
mailing list.

Also, derby controlled by derby.war doesn't start (normally) until the 
web application is accessed (http://localhost:8080/derby/derbynet is the 

To get around the first, you can use a validation query (if your pooling 
supports it) with a retry / timeout. I use Tomcat's pooling and JNDI so 
this works for me. I know you can coerce Hibernate to use Tomcat's 
database pooling and JNDI, so I imagine you can do the same with Spring. 
If not, then hopefully you can configure your pooling to use a validation 
query to make sure that the database is up and running.

To get around the second, you can add the following line to the servlet 
element in web.xml:


This will start the Derby network server running without having to access 
the derbynet URL.

Hopefully you've done things like add derby.jar, derbynet.jar, 
derbyclient.jar to the appropriate place in Tomcat ($CATALINA_HOME/common/
lib for Tomcat 5.5.x, $CATALINA_HOME/lib for Tomcat 6.0.x and 7.0.x). 
It's also probably a good idea to set derby.system.home outside of the 
webapps area. Add -Dderby.system.home=somewhere to JAVA_OPTS in 
$CATALINA_HOME/bin/setenv.sh (create if you don't have one already).

, , , , just my two cents.


View raw message