I have two applications deployed on tomcat. For each application I have defined their own context in $CATALINA_HOME/conf/Catalina/localhost where JDBC datasource is defined. When I undeploy one of the application using ant script con开发者_如何学Gotext of this application is deleted, so on the next start of the tomcat application cannot be deployed because it doesnt have JDBC connection defined. Is there any solution to this problem?
I think this is a Tomcat bug. I filed a bug report but the fix is complicated.
Tomcat can deploy application in 3 ways,
- Directory, like webapps/myapp.
- WAR, like webapps/myapp.war.
- Context fragment, which is what you are using.
If you use #3 but the app or war are in webapps, Tomcat will be confused with #1 or #2. When redeploying directory or war, it supposes to remove context fragment.
My workarounds are,
- If you use directory, put it somewhere other than APPBASE (webapps). If you use WAR, put it somewhere else also and don't explode it.
- We deploy our app using a script. In the script, the fragment is copied over every time after app is undeployed.
Here is a sample fragment for WAR deployment,
<Context docBase="/anywhere/but/webapps/myapp.war"
swallowOutput="true" unpackWAR="false" />
Please notice not every app runs in unpacked mode. You can't read any resources as files from the WAR in unpacked mode.
精彩评论