Reputation: 8719
So far we have been using Tomcat 6 where we specify the war to be deployed in context.xml file under $CATALINA_HOME/conf/Catalina/localhost as application1-context.xml, application2-context.xml. etc.
example application1-context.xml
<Context path="/myapps/app1" docBase="C:\warfiles\appOne.war"
debug="0" privileged="true">
<Loader className="MyCustomApplicationLoader"/>
<Logger className="org.apache.catalina.logger.SystemOutLogger" verbosity="4" timestamp="true"/>
</Context>
This would create a folder myapps#app1 under $CATALINA_HOME/webapps folder.
But since migrating to Tomcat7, this does not happen any more. Unless I have the war file "appone.war" directly under the tomcat appBase directory i.e. $CATALINA_HOME/webapps my war will not be unpacked into a folder under $CATALINA_HOME/webapps directory.
I have read this apache bug report: https://issues.apache.org/bugzilla/show_bug.cgi?id=51294"%3B>%3B51294<%3B/a>%3B
Question: Is there any way we can force this behavior in tomcat 7?
Upvotes: 2
Views: 2669
Reputation: 1263
It sounds like this issue has been fixed in Tomcat version 7.0.48 which, at the time of writing, is still in development. It's also been added to version 8.
Edit: I have managed to resolve this without having to wait for/use 7.0.48. In your context.xml file add unpackWAR="false"
and specify the virtualClasspath
attribute so it points to your target\classes folder like so:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="(path to .war file)">
<Loader className="org.apache.catalina.loader.VirtualWebappLoader"
virtualClasspath="(path to folder contain .class files,
usually {project folder}\target\classes\)"
searchExternalFirst="true"
unpackWAR="false" />
</Context>
searchExternalFirst
means that the class loader will look in your virtualClasspath
folder before looking in the WEB-INF directory.unpackWAR
is set to false because your war file will already be exploded in the /target/classes folder so there's no need for Tomcat to do it as well.Hopefully this helps you too.
Upvotes: 1
Reputation: 1996
Try <Context unpackWARs="true" ...
Files under conf/catalina/... should not be changed manual. They are created automatically if not exists on first start of the webapp. You should never change these files, delete them instead and let them be created new from tomcat itself (they are composed by the war's /META-INF/context.xml
-File if exists).
Upvotes: 0