views:

375

answers:

2

I'm configuring an installer for our product which, up until now, was distributed as a war file, usually on tomcat. Once tomcat has exploded the directory, the user has to open a properties file and set their database connection information. I'd like the installer to do this (we're using install4j) but there doesn't seem to be a built-in way to modify a text file inside a war file. I could just have the installer deploy the app as an exploded directory, which would save me the trouble here, but what do I lose by deploying like that instead of deploying the war?

+1  A: 

It might work better to set up the database connection as a JNDI Datasource, rather than hand-editing a properties file inside the webapp/ directory. This is especially important if you want to allow users to re-deploy the application from the .WAR archive without overwriting their local configuration changes.

Of course, the JNDI setup isn't going to be trivially accomplished through the installer, either, since the mechanism used varies from app server to app server. However, any competent Java application server administrator should know how to configure a named datasource. Furthermore, by delegating responsibility to the app server, you allow your users to take advantage of connection pooling, clustering, and any other features provided by the datasource implementation bundled with their application server of choice.

rcoder
The product is targeted at people who don't really know what they're doing, hence the installer ;) We're actually bundling tomcat and mysql with it, which I should have said above.
jobrahms
In that case, your installer should configure the Tomcat JNDI Database programatically, and leave the WAR contents alone. Tomcat's configuration syntax is well-documented XML, and stable across server restarts and webapp re-deploy operations.
rcoder
A: 

Not much I would think - perhaps a bit of disk space, but if that's not a problem you'd be fine. Have you thought of having the installer generate the properties file and using a ZIP library (.WAR is really a .ZIP - rename it to a .ZIP and see what you get :) ) to replace or add it in?

Fritz H
Yeah, I knew it's a zip. I'm just wondering if tomcat does anything differently re: deploying/undeploying when it gets a folder instead of a war file. If I can get away with deploying the folder, it'll save me the trouble of having to write something extra to handle the zip file.
jobrahms