You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Leo Donahue - PLANDEVX <Le...@mail.maricopa.gov> on 2010/05/10 03:16:39 UTC

Context in conf/Catalina/localhost question

I've noticed that sometimes when I make a change to an existing webapp or deploy a new one, that the file contents created in conf/Catalina/localhost do not match the contents of the context file in META-INF/context.xml of the webapp dir.

Tomcat 6.0.24 - still. Upgrade is coming.

Example, I added a valve to each of my webapps context.xml to turn on the access logs.  The valve was the same for each webap, I only changed the name of the access log file name.  Three of four webapps produced a log file, but one webapp would not produce an access log file, no matter how many times I restarted Tomcat - deleted the cache in the work directory and removed previous entries in conf/Catalina/localhost.

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
"... You may define as many Context elements as you wish. Each such Context MUST have a unique context path. In addition, a Context must be present with a context path equal to a zero-length string. This Context becomes the default web application for this virtual host, and is used to process all requests that do not match any other Context's context path ..."


Contents of the apnxy servlet META-INF/context.xml that keep appearing in conf/Catalina/localhost, and I didn't even have the path attribute set in that file:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/apnxy">
</Context>


I finally just stopped Tomcat, deleted the cache in work dir, renamed and manually copied the apnxy.xml file from META-INF/context.xml to conf/Catalina/localhost and started Tomcat.  Access log for apnxy_... appeared.  What did I miss?


Contents of each access log valve:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true">
        <!-- Log all requests to Tomcat root -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
        prefix="apnxy_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Context>



Contents of context.xml in conf directory:

<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>

Leo



RE: Context in conf/Catalina/localhost question

Posted by Mark Eggers <it...@yahoo.com>.
I just ran a series of tests on my Linux platform. I've not rebooted yet to run this on Windows, but I don't imagine there will be any change.

Environment (all 32 bit):

OS:          Fedora 11 with latest patches
Java:        JRE / JDK 1.6.0_20 from Sun
Tomcat:      6.0.26 installed in my local account for development / testing
NetBeans:    6.8 installed globally in /opt/netbeans-6.8
Application: DVDStore based on the NetBeans tutorial

Scenario 1

a. Start NetBeans
b. Load standard project (DVDStore)
c. Set as main project
d. Run (without building first)

Expected result: Browser with new tab containing the application pops up
Actual result:   Browser with new tab containing the application pops up

DVDStore.xml generated in $CATALINA_HOME/conf/Catalina/localhost contains path="/DVDStore" and appBase="/home/mdeggers/NB8-Projects/DVDStore/build/web"

I did not put these entries into web/META-INF/context.xml in the source tree.

Right mouse clicking on the project node and selecting clean removes
$CATALINA_HOME/conf/Catalina/localhost/DVDStore.xml and all traces of the web application from $CATALINA_HOME/work/Catalina/localhost.

Scenario 2

a. Clean and build web application
b. Use Tomcat manager to deploy web application (DVDStore)
c. Browse to localhost:8080/DVDStore

Expected result: Application works as before
Actual result:   Application works as before

Note that in this case, the $CATALINA_HOME/conf/Catalina/localhost/DVDStore.xml file does NOT have the path or docBase attributes in <Context>.

Undeploying via the Tomcat manager cleanly removes all traces (war file, webapps directory, work directory, and DVDStore.xml).

Trivial modifications of a JSP file (adding a <meta content="blah"> item) appear immediately in the running application if I started with F6 (run).

I did manage to run into the posted exception once, but I have been unable to reproduce it.

Cleaning out .netbeans/6.8/var/cache may help.

Summary:

Do not add appBase and path to META-INF/context.xml in the actual project. NetBeans 6.8 seems to manage that properly (merging existing context.xml information with the path and appBase attributes).

. . . . just my two cents

/mde/

--- On Mon, 5/10/10, Leo Donahue - PLANDEVX <Le...@mail.maricopa.gov> wrote:

> From: Leo Donahue - PLANDEVX <Le...@mail.maricopa.gov>
> Subject: RE: Context in conf/Catalina/localhost question
> To: "'Tomcat Users List'" <us...@tomcat.apache.org>
> Date: Monday, May 10, 2010, 3:02 PM
> NetBeans 6.8 Output window:
> 
> In-place deployment at
> C:\NetBeans_Projects\webappname\build\web
> Cannot deploy the module. The context.xml file seems to be
> broken. Check whether it is well-formed and valid.
> C:\NetBeans_Projects\webappname\nbproject\build-impl.xml:584:
> The module has not been deployed.
> 
> 
> 
> -----Original Message-----
> From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov]
> 
> Sent: Monday, May 10, 2010 2:51 PM
> To: 'Tomcat Users List'
> Subject: RE: Context in conf/Catalina/localhost question
> 
> NetBeans 6.8 won't even run the webapp within the IDE
> unless the path attribute is set in
> META-INF/context.xml  I understand why the IDE needs
> the path to run the webapp from the the NetBeans work
> directory, but do the NetBeans people talk to the Tomcat
> people? :)
> 
> Maybe, the clean and build tool in NetBeans could strip
> that out when it creates the war file?  I'm just
> saying.  People forget.
> 
> 
> -----Original Message-----
> From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov]
> Sent: Sunday, May 09, 2010 6:27 PM
> To: 'Tomcat Users List'
> Subject: RE: Context in conf/Catalina/localhost question
> 
> This always happens.  Once I send a question I find
> the answer.  Normally I've been copying expanded webapp
> directories to the webapps folder when I have Tomcat stopped
> for other server maintenance.  I forgot that I
> experimented with deploying a war file for the apnxy
> servlet.  I'm going to point the finger at NetBeans for
> adding the path attribute to my context.  Tomcat was
> just doing what it is supposed to under automatic
> deployment:  http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment
> 
> 
> 
> -----Original Message-----
> From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov]
> Sent: Sunday, May 09, 2010 6:17 PM
> To: 'Tomcat Users List'
> Subject: Context in conf/Catalina/localhost question
> 
> I've noticed that sometimes when I make a change to an
> existing webapp or deploy a new one, that the file contents
> created in conf/Catalina/localhost do not match the contents
> of the context file in META-INF/context.xml of the webapp
> dir.
> 
> Tomcat 6.0.24 - still. Upgrade is coming.
> 
> Example, I added a valve to each of my webapps context.xml
> to turn on the access logs.  The valve was the same for
> each webap, I only changed the name of the access log file
> name.  Three of four webapps produced a log file, but
> one webapp would not produce an access log file, no matter
> how many times I restarted Tomcat - deleted the cache in the
> work directory and removed previous entries in
> conf/Catalina/localhost.
> 
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
> "... You may define as many Context elements as you wish.
> Each such Context MUST have a unique context path. In
> addition, a Context must be present with a context path
> equal to a zero-length string. This Context becomes the
> default web application for this virtual host, and is used
> to process all requests that do not match any other
> Context's context path ..."
> 
> 
> Contents of the apnxy servlet META-INF/context.xml that
> keep appearing in conf/Catalina/localhost, and I didn't even
> have the path attribute set in that file:
> <?xml version="1.0" encoding="UTF-8"?>
> <Context antiJARLocking="true" path="/apnxy">
> </Context>
> 
> 
> I finally just stopped Tomcat, deleted the cache in work
> dir, renamed and manually copied the apnxy.xml file from
> META-INF/context.xml to conf/Catalina/localhost and started
> Tomcat.  Access log for apnxy_... appeared.  What
> did I miss?
> 
> 
> Contents of each access log valve:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <Context antiJARLocking="true">
>         <!-- Log all requests to
> Tomcat root -->
>         <Valve
> className="org.apache.catalina.valves.AccessLogValve"
> directory="logs"
>         prefix="apnxy_access_log."
> suffix=".txt" pattern="common" resolveHosts="false"/>
> </Context>
> 
> 
> 
> Contents of context.xml in conf directory:
> 
> <?xml version='1.0' encoding='utf-8'?>
> <!-- The contents of this file will be loaded for each
> web application --> <Context>
> 
>     <!-- Default set of monitored resources
> -->
>    
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
> 
>     <!-- Uncomment this to disable session
> persistence across Tomcat restarts -->
>     <!--
>     <Manager pathname="" />
>     -->
> 
>     <!-- Uncomment this to enable Comet
> connection tacking (provides events
>          on session
> expiration as well as webapp lifecycle) -->
>     <!--
>     <Valve
> className="org.apache.catalina.valves.CometConnectionManagerValve"
> />
>     -->
> 
> </Context>
> 
> Leo



      


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


RE: Context in conf/Catalina/localhost question

Posted by Leo Donahue - PLANDEVX <Le...@mail.maricopa.gov>.
NetBeans 6.8 Output window:

In-place deployment at C:\NetBeans_Projects\webappname\build\web
Cannot deploy the module. The context.xml file seems to be broken. Check whether it is well-formed and valid.
C:\NetBeans_Projects\webappname\nbproject\build-impl.xml:584: The module has not been deployed.



-----Original Message-----
From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov] 
Sent: Monday, May 10, 2010 2:51 PM
To: 'Tomcat Users List'
Subject: RE: Context in conf/Catalina/localhost question

NetBeans 6.8 won't even run the webapp within the IDE unless the path attribute is set in META-INF/context.xml  I understand why the IDE needs the path to run the webapp from the the NetBeans work directory, but do the NetBeans people talk to the Tomcat people? :)

Maybe, the clean and build tool in NetBeans could strip that out when it creates the war file?  I'm just saying.  People forget.


-----Original Message-----
From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov]
Sent: Sunday, May 09, 2010 6:27 PM
To: 'Tomcat Users List'
Subject: RE: Context in conf/Catalina/localhost question

This always happens.  Once I send a question I find the answer.  Normally I've been copying expanded webapp directories to the webapps folder when I have Tomcat stopped for other server maintenance.  I forgot that I experimented with deploying a war file for the apnxy servlet.  I'm going to point the finger at NetBeans for adding the path attribute to my context.  Tomcat was just doing what it is supposed to under automatic deployment:  http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment



-----Original Message-----
From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov]
Sent: Sunday, May 09, 2010 6:17 PM
To: 'Tomcat Users List'
Subject: Context in conf/Catalina/localhost question

I've noticed that sometimes when I make a change to an existing webapp or deploy a new one, that the file contents created in conf/Catalina/localhost do not match the contents of the context file in META-INF/context.xml of the webapp dir.

Tomcat 6.0.24 - still. Upgrade is coming.

Example, I added a valve to each of my webapps context.xml to turn on the access logs.  The valve was the same for each webap, I only changed the name of the access log file name.  Three of four webapps produced a log file, but one webapp would not produce an access log file, no matter how many times I restarted Tomcat - deleted the cache in the work directory and removed previous entries in conf/Catalina/localhost.

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
"... You may define as many Context elements as you wish. Each such Context MUST have a unique context path. In addition, a Context must be present with a context path equal to a zero-length string. This Context becomes the default web application for this virtual host, and is used to process all requests that do not match any other Context's context path ..."


Contents of the apnxy servlet META-INF/context.xml that keep appearing in conf/Catalina/localhost, and I didn't even have the path attribute set in that file:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/apnxy"> </Context>


I finally just stopped Tomcat, deleted the cache in work dir, renamed and manually copied the apnxy.xml file from META-INF/context.xml to conf/Catalina/localhost and started Tomcat.  Access log for apnxy_... appeared.  What did I miss?


Contents of each access log valve:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true">
        <!-- Log all requests to Tomcat root -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
        prefix="apnxy_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> </Context>



Contents of context.xml in conf directory:

<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application --> <Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>

Leo



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


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


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


RE: Context in conf/Catalina/localhost question

Posted by Leo Donahue - PLANDEVX <Le...@mail.maricopa.gov>.
NetBeans 6.8 won't even run the webapp within the IDE unless the path attribute is set in META-INF/context.xml  I understand why the IDE needs the path to run the webapp from the the NetBeans work directory, but do the NetBeans people talk to the Tomcat people? :)

Maybe, the clean and build tool in NetBeans could strip that out when it creates the war file?  I'm just saying.  People forget.


-----Original Message-----
From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov] 
Sent: Sunday, May 09, 2010 6:27 PM
To: 'Tomcat Users List'
Subject: RE: Context in conf/Catalina/localhost question

This always happens.  Once I send a question I find the answer.  Normally I've been copying expanded webapp directories to the webapps folder when I have Tomcat stopped for other server maintenance.  I forgot that I experimented with deploying a war file for the apnxy servlet.  I'm going to point the finger at NetBeans for adding the path attribute to my context.  Tomcat was just doing what it is supposed to under automatic deployment:  http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment



-----Original Message-----
From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov]
Sent: Sunday, May 09, 2010 6:17 PM
To: 'Tomcat Users List'
Subject: Context in conf/Catalina/localhost question

I've noticed that sometimes when I make a change to an existing webapp or deploy a new one, that the file contents created in conf/Catalina/localhost do not match the contents of the context file in META-INF/context.xml of the webapp dir.

Tomcat 6.0.24 - still. Upgrade is coming.

Example, I added a valve to each of my webapps context.xml to turn on the access logs.  The valve was the same for each webap, I only changed the name of the access log file name.  Three of four webapps produced a log file, but one webapp would not produce an access log file, no matter how many times I restarted Tomcat - deleted the cache in the work directory and removed previous entries in conf/Catalina/localhost.

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
"... You may define as many Context elements as you wish. Each such Context MUST have a unique context path. In addition, a Context must be present with a context path equal to a zero-length string. This Context becomes the default web application for this virtual host, and is used to process all requests that do not match any other Context's context path ..."


Contents of the apnxy servlet META-INF/context.xml that keep appearing in conf/Catalina/localhost, and I didn't even have the path attribute set in that file:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/apnxy"> </Context>


I finally just stopped Tomcat, deleted the cache in work dir, renamed and manually copied the apnxy.xml file from META-INF/context.xml to conf/Catalina/localhost and started Tomcat.  Access log for apnxy_... appeared.  What did I miss?


Contents of each access log valve:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true">
        <!-- Log all requests to Tomcat root -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
        prefix="apnxy_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> </Context>



Contents of context.xml in conf directory:

<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application --> <Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>

Leo



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


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


RE: Context in conf/Catalina/localhost question

Posted by Leo Donahue - PLANDEVX <Le...@mail.maricopa.gov>.
This always happens.  Once I send a question I find the answer.  Normally I've been copying expanded webapp directories to the webapps folder when I have Tomcat stopped for other server maintenance.  I forgot that I experimented with deploying a war file for the apnxy servlet.  I'm going to point the finger at NetBeans for adding the path attribute to my context.  Tomcat was just doing what it is supposed to under automatic deployment:  http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment



-----Original Message-----
From: Leo Donahue - PLANDEVX [mailto:LeoDonahue@mail.maricopa.gov] 
Sent: Sunday, May 09, 2010 6:17 PM
To: 'Tomcat Users List'
Subject: Context in conf/Catalina/localhost question

I've noticed that sometimes when I make a change to an existing webapp or deploy a new one, that the file contents created in conf/Catalina/localhost do not match the contents of the context file in META-INF/context.xml of the webapp dir.

Tomcat 6.0.24 - still. Upgrade is coming.

Example, I added a valve to each of my webapps context.xml to turn on the access logs.  The valve was the same for each webap, I only changed the name of the access log file name.  Three of four webapps produced a log file, but one webapp would not produce an access log file, no matter how many times I restarted Tomcat - deleted the cache in the work directory and removed previous entries in conf/Catalina/localhost.

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
"... You may define as many Context elements as you wish. Each such Context MUST have a unique context path. In addition, a Context must be present with a context path equal to a zero-length string. This Context becomes the default web application for this virtual host, and is used to process all requests that do not match any other Context's context path ..."


Contents of the apnxy servlet META-INF/context.xml that keep appearing in conf/Catalina/localhost, and I didn't even have the path attribute set in that file:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/apnxy"> </Context>


I finally just stopped Tomcat, deleted the cache in work dir, renamed and manually copied the apnxy.xml file from META-INF/context.xml to conf/Catalina/localhost and started Tomcat.  Access log for apnxy_... appeared.  What did I miss?


Contents of each access log valve:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true">
        <!-- Log all requests to Tomcat root -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
        prefix="apnxy_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> </Context>



Contents of context.xml in conf directory:

<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application --> <Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->

</Context>

Leo



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