开发者

Deleted context on undeploy

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,

  1. Directory, like webapps/myapp.
  2. WAR, like webapps/myapp.war.
  3. 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,

  1. 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.
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜