You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Junek Leoš <ju...@oksystem.cz> on 2014/05/14 10:04:37 UTC

ROOT context - WAR is not unpacked

Hello to all,

I am using Tomcat 7.0.29 (from ZIP got at Tomcat Apache site), Oracle Linux 6.4 and want to deploy "myapp" to ROOT context using virtualhost. My actual settings is according Tomcat documentation

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming
If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:

a)     Disable autoDeploy and deployOnStartup and define all Contexts in server.xml

b)    Locate the WAR and/or directory outside of the Host's appBase and use a context.xml file with a docBase attribute to define it.

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Defining_a_context

Individual Context elements may be explicitly defined:

A.    In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to application's base file name plus a ".xml" extension.

B.    In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The context path and version will be derived from the base name of the file (the file name less the .xml extension). This file will always take precedence over any context.xml file packaged in the web application's META-INF directory.

C.    Inside a Host element in the main conf/server.xml.

Application "myapp" should be

1.     Deployed with context path=""

2.     Named myapp.war (not ROOT.war)

3.     In unpacked WAR file META-INF/context.xml should not be edited.

4.     Should be unpacked/deployed only once.

To fulfill above tasks, I have

-       Defined virtualhost named "myapphostname" with appbasedir $CATALINA_HOME/myapp_dst (dst from destination)

-       Placed myapp.war to folder $CATALINA_HOME/myapp_src (src from source)

-       Created file $CATALINA_HOME/conf/Catalina/myapphost/ROOT.xml with context path="" docBase=$CATALINA_HOME/myapp_src/myapp.war

-       As you can see, options b) and B. were chosen.

I expected myapp.war to be unpacked to host appBase, i.e. in $CATALINA_HOME/myapp_dst, either to $CATALINA_HOME/myapp_dst/ROOT or $CATALINA_HOME/myapp_dst/myapp, but it was not unpacked, however myapp is running from WAR.

What should be changed in config files or directory structure to let myapp.war to be unpacked?

=== directory structure (only relevant files) ===
$CATALINA_BASE
|-- bin
|-- conf
|   |-- Catalina
|   |   |-- localhost
|   |   `-- myapphost
|   |       `-- ROOT.xml
|   |-- catalina.policy
|   |-- catalina.properties
|   |-- context.xml
|   |-- logging.properties
|   |-- server.xml
|   |-- tomcat-users.xml
|   `-- web.xml
|-- lib
|-- LICENSE
|-- logs
|-- NOTICE
|-- myapp_dst
|   |-- mysecondapp
|   `-- mysecondapp.war
|-- myapp_src
|   `-- myapp.war
|-- RELEASE-NOTES
|-- temp
|-- webapps
`-- work

=== server.xml ===
    <Engine name="Catalina" defaultHost="myapphost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>

      <Host name="myapphost" appBase="myapp_dst" unpackWARs="true" autoDeploy="true">
      </Host>
    </Engine>

=== $CATALINA_HOME/conf/Catalina/okbasehost/ROOT.xml ===
<Context path="" docBase="/opt/programs/tomcat7b/myapp_src/myapp.war" />


I will be happy if you can help me.

With regards


Best Regards.

Leoš Junek, IT Systems Administrator
OKsystem s.r.o.
Na Pankráci 125, 140 21 Praha 4, Czech Republic
tel: +420 236 072 268, fax: +420 236 072 112, mobile: +420 776 679 792
e-mail: junek@oksystem.cz<ma...@oksystem.cz>, web: www.oksystem.cz<http://www.oksystem.cz>




________________________________

Upozornění společnosti OKsystem s.r.o. s ohledem na zavedené standardy ISO 9001, ISO 27001 a ISO 14001:
Tato zpráva a všechny připojené soubory jsou dle obchodního zákoníku důvěrné. Jestliže nejste zamýšleným adresátem, uvědomte prosím odesilatele a smažte zprávu i přiložené soubory.
Opravdu potřebujete vytisknout tento email? Myslete na přírodu.

Disclaimer of OKsystem s.r.o. with respect to implemented standards ISO 9001, ISO 27001 and ISO 14001:
This message and all attached files are confidential and legally privileged. If you are not the intended recipient, please notify the sender and delete the message including all attachments.
Please consider the environment before printing this email.

Re: ROOT context - WAR is not unpacked

Posted by Mark Thomas <ma...@apache.org>.
On 14/05/2014 09:04, Junek Leoš wrote:
> Hello to all,
> 
> I am using Tomcat 7.0.29 (from ZIP got at Tomcat Apache site), Oracle Linux 6.4 and want to deploy "myapp" to ROOT context using virtualhost. My actual settings is according Tomcat documentation
> 
> http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming

That is the documentation for the latest release. You are using a
release from almost 2 years ago.

There really is no need to quote the documentation at this sort of
length. We are all quite capable of following a link (if we don't
already know what the docs say.

<snip/>

> Application "myapp" should be
> 
> 1.     Deployed with context path=""
> 
> 2.     Named myapp.war (not ROOT.war)
> 
> 3.     In unpacked WAR file META-INF/context.xml should not be edited.
> 
> 4.     Should be unpacked/deployed only once.
> 
> To fulfill above tasks, I have
> 
> -       Defined virtualhost named "myapphostname" with appbasedir $CATALINA_HOME/myapp_dst (dst from destination)
> 
> -       Placed myapp.war to folder $CATALINA_HOME/myapp_src (src from source)
> 
> -       Created file $CATALINA_HOME/conf/Catalina/myapphost/ROOT.xml with context path="" docBase=$CATALINA_HOME/myapp_src/myapp.war
> 
> -       As you can see, options b) and B. were chosen.
> 
> I expected myapp.war to be unpacked to host appBase, i.e. in $CATALINA_HOME/myapp_dst, either to $CATALINA_HOME/myapp_dst/ROOT or $CATALINA_HOME/myapp_dst/myapp, but it was not unpacked, however myapp is running from WAR.

As is entirely expected for the version of Tomcat you are running.

> What should be changed in config files or directory structure to let myapp.war to be unpacked?

The behaviour you require is not available with the version of Tomcat
you are currently running.

Uninstall the out of date version you currently have and install the
latest 7.0.x release.

For details of when this behaviour changed, see the change log.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org