You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel Blumenthal <da...@wordchamp.com> on 2008/08/15 19:40:23 UTC

reloadable problem with filters

I'm having an odd problem.  When filters are enabled in my application
(e.g., to add an "Expires" header to certain files), I have to restart the
tomcat server every time I recompile.  When the filters are disabled, I
don't have to restart the server (i.e., "reloadable" works).
 
tomcat/conf/web.xml:
 
<Context reloadable="true">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
 
>From WEB-INF/web.xml:
 
...
<filter>
    <filter-name>ExpiresFilter</filter-name>
    <filter-class>app.ExpiresFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ExpiresFilter</filter-name>
    <url-pattern>*.js</url-pattern>
</filter-mapping>
...
 
Any thoughts on why this would be happening, or workarounds?

Re: reloadable problem with filters

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel,

Daniel Blumenthal wrote:
> I'm actually getting an error in catalina.out *during compilation* (see log
> extract below).

That's deployment, not compilation.

> I think that what's happening is that somehow the reload
> process is being triggered early, during the build process, before
> everything's ready.

Do you build directly into your deployment directory? That can be
dangerous, because there is a race condition with the server. Try
re-deploying a WAR file using the manager app or simply overwriting your
WAR file while the server is running. Does that work?

Here's your problem:
> SEVERE: Context [/myapp] startup failed du to previous errors

Due to what I believe is premature reloading, your webapp fails to start
up properly. After a failed startup, Tomcat will not automatically
reload the webapp for any reason: you'll need to do it manually, either
by using the manager webapp or by bounding the entire TC instance.

> My guess is that this is being caused by the filter
> getting compiled - perhaps this is caused by the line in context.xml?
> ("<WatchedResource>WEB-INF/web.xml</WatchedResource>")

That just configures Tomcat to "watch" META-INF/web.xml for changes. If
the file is touched, Tomcat will reload. This is the default behavior,
so adding this to your own context.xml file doesn't actually accomplish
anything.

Your ClassCastException is probably due to a new version of the Class
being loaded into the container, while an object of the old, outdated
class was stored in session or application scope across the reload.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiph6sACgkQ9CaO5/Lv0PDvYwCggDSe75wPShV9pDZJ0ttcQ3vY
ca4AoID38fpN1a0c08Px1nMEbsfrgQGd
=p+wG
-----END PGP SIGNATURE-----

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


RE: reloadable problem with filters

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Daniel Blumenthal [mailto:daniel@wordchamp.com]
> Subject: RE: reloadable problem with filters
>
> On my development machine, I do compile into the same
> directory that I'm running from.

You could try turning off autoDeploy and then manually initiate a redeployment when the compilations are done.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


RE: reloadable problem with filters

Posted by Daniel Blumenthal <da...@wordchamp.com>.
On my development machine, I do compile into the same directory that I'm
running from.  Is there a more effective development configuration?


> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Sent: Friday, August 15, 2008 4:50 PM
> To: Tomcat Users List
> Subject: RE: reloadable problem with filters
> 
> > From: Daniel Blumenthal [mailto:daniel@wordchamp.com]
> > Subject: RE: reloadable problem with filters
> >
> > I'm actually getting an error in catalina.out *during
> > compilation* (see log extract below).
> 
> Are you compiling into the deployment directory of an active 
> application?  I don't know how you could ever make that work 
> reliably, especially if more than one class is compiled at a time.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE 
> PROPRIETARY MATERIAL and is thus for use only by the intended 
> recipient. If you received this in error, please contact the 
> sender and delete the e-mail and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


RE: reloadable problem with filters

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Daniel Blumenthal [mailto:daniel@wordchamp.com]
> Subject: RE: reloadable problem with filters
>
> I'm actually getting an error in catalina.out *during
> compilation* (see log extract below).

Are you compiling into the deployment directory of an active application?  I don't know how you could ever make that work reliably, especially if more than one class is compiled at a time.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

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


RE: reloadable problem with filters

Posted by Daniel Blumenthal <da...@wordchamp.com>.
Unfortunately, neither renaming the file to ZZExpiresFilter.java nor
removing the line from the config file appears to be having an effect.


> -----Original Message-----
> From: Daniel Blumenthal [mailto:daniel@wordchamp.com] 
> Sent: Friday, August 15, 2008 4:34 PM
> To: 'Tomcat Users List'
> Subject: RE: reloadable problem with filters
> 
> Hi Chris,
> 
> Unfortunately, I don't think it's related to that.
> 
> The "reloadable" attribute has been working like a champ for 
> me.  But today, I added a filter (a new class, created 
> today).  As soon as I added the configuration to the web.xml 
> file, I started having to restart the Tomcat server after 
> each compile.
> 
> If I comment out the <filter> tags from web.xml, everything 
> works fine.  If I uncomment just the <filter>...</filter> 
> section, I start getting this behavior again.
> 
> I'm actually getting an error in catalina.out *during 
> compilation* (see log extract below).  I think that what's 
> happening is that somehow the reload process is being 
> triggered early, during the build process, before 
> everything's ready.  My guess is that this is being caused by 
> the filter getting compiled - perhaps this is caused by the 
> line in context.xml?
> ("<WatchedResource>WEB-INF/web.xml</WatchedResource>")
> 
> I'm going to see what happens if I rename the filter to 
> "ZZFilter" (to try to change the build order).
> 
> Daniel
> 
> 
> <start compilation at 4:23:25 PM>
> 
> Aug 15, 2008 4:23:30 PM org.apache.catalina.loader.WabappClassLoader
> modified
> SEVERE:	Resource 
> '/WEB-INF/classes/app/ExpiresFilter.class' is missing
> Aug 15, 2008 4:23:30 PM 
> org.apache.catalina.core.StandardContext reload
> INFO: Reloading this Context has started Aug 15, 2008 4:23:35 
> PM org.apache.catalina.session.StandardManager doLoad
> SEVERE: ClassNotFoundException while loading persisted sessions:
> java.lang.ClassNotFoundException: app.MyClass ... (stack 
> dump) Aug 15, 2008 4:23:35 PM 
> org.apache.catalina.session.StandardManager start
> SEVERE: Exception loading session from persistent storage ... 
> (stack dump) Aug 15, 2008 4:23:35 PM 
> org.apache.catalina.session.StandardContext start
> SEVERE: Error filterStart
> Aug 15, 2008 4:23:35 PM 
> org.apache.catalina.session.StandardContext start
> SEVERE: Context [/myapp] startup failed du to previous errors
> 
> <compilation completes at 4:23:40 PM>
> 
> 
> > -----Original Message-----
> > From: Christopher Schultz [mailto:chris@christopherschultz.net]
> > Sent: Friday, August 15, 2008 3:32 PM
> > To: Tomcat Users List
> > Subject: Re: reloadable problem with filters
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > Daniel,
> > 
> > Daniel Blumenthal wrote:
> > > I'm having an odd problem.  When filters are enabled in my
> > application
> > > (e.g., to add an "Expires" header to certain files), I have
> > to restart
> > > the tomcat server every time I recompile.  When the filters are 
> > > disabled, I don't have to restart the server (i.e.,
> > "reloadable" works).
> > 
> > Tomcat should be restarting when reloadable=true and your 
> install new 
> > class files regardless of the filter configuration.
> > 
> > One thing I've found is that if you don't actually /use/ a 
> particular 
> > class, and then you update it, Tomcat will not reload the webapp. 
> > Could this be the behavior you are experiencing?
> > 
> > - -chris
> > 
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.9 (MingW32)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> > 
> > iEYEARECAAYFAkil2ZcACgkQ9CaO5/Lv0PCerACfb3GTPDWMECHz6XWmOAekWdPb
> > UK0An1cwuOxVKTh9NgU1ydJJcMJ0xwur
> > =/13/
> > -----END PGP SIGNATURE-----
> > 
> > 
> ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, 
> > e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


RE: reloadable problem with filters

Posted by Daniel Blumenthal <da...@wordchamp.com>.
Hi Chris,

Unfortunately, I don't think it's related to that.

The "reloadable" attribute has been working like a champ for me.  But today,
I added a filter (a new class, created today).  As soon as I added the
configuration to the web.xml file, I started having to restart the Tomcat
server after each compile.

If I comment out the <filter> tags from web.xml, everything works fine.  If
I uncomment just the <filter>...</filter> section, I start getting this
behavior again.

I'm actually getting an error in catalina.out *during compilation* (see log
extract below).  I think that what's happening is that somehow the reload
process is being triggered early, during the build process, before
everything's ready.  My guess is that this is being caused by the filter
getting compiled - perhaps this is caused by the line in context.xml?
("<WatchedResource>WEB-INF/web.xml</WatchedResource>")

I'm going to see what happens if I rename the filter to "ZZFilter" (to try
to change the build order).

Daniel


<start compilation at 4:23:25 PM>

Aug 15, 2008 4:23:30 PM org.apache.catalina.loader.WabappClassLoader
modified
SEVERE:	Resource '/WEB-INF/classes/app/ExpiresFilter.class' is missing
Aug 15, 2008 4:23:30 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Aug 15, 2008 4:23:35 PM org.apache.catalina.session.StandardManager doLoad
SEVERE: ClassNotFoundException while loading persisted sessions:
java.lang.ClassNotFoundException: app.MyClass
... (stack dump)
Aug 15, 2008 4:23:35 PM org.apache.catalina.session.StandardManager start
SEVERE: Exception loading session from persistent storage
... (stack dump)
Aug 15, 2008 4:23:35 PM org.apache.catalina.session.StandardContext start
SEVERE: Error filterStart
Aug 15, 2008 4:23:35 PM org.apache.catalina.session.StandardContext start
SEVERE: Context [/myapp] startup failed du to previous errors

<compilation completes at 4:23:40 PM>


> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Sent: Friday, August 15, 2008 3:32 PM
> To: Tomcat Users List
> Subject: Re: reloadable problem with filters
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Daniel,
> 
> Daniel Blumenthal wrote:
> > I'm having an odd problem.  When filters are enabled in my 
> application 
> > (e.g., to add an "Expires" header to certain files), I have 
> to restart 
> > the tomcat server every time I recompile.  When the filters are 
> > disabled, I don't have to restart the server (i.e., 
> "reloadable" works).
> 
> Tomcat should be restarting when reloadable=true and your 
> install new class files regardless of the filter configuration.
> 
> One thing I've found is that if you don't actually /use/ a 
> particular class, and then you update it, Tomcat will not 
> reload the webapp. Could this be the behavior you are experiencing?
> 
> - -chris
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAkil2ZcACgkQ9CaO5/Lv0PCerACfb3GTPDWMECHz6XWmOAekWdPb
> UK0An1cwuOxVKTh9NgU1ydJJcMJ0xwur
> =/13/
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: reloadable problem with filters

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel,

Daniel Blumenthal wrote:
> I'm having an odd problem.  When filters are enabled in my application
> (e.g., to add an "Expires" header to certain files), I have to restart the
> tomcat server every time I recompile.  When the filters are disabled, I
> don't have to restart the server (i.e., "reloadable" works).

Tomcat should be restarting when reloadable=true and your install new
class files regardless of the filter configuration.

One thing I've found is that if you don't actually /use/ a particular
class, and then you update it, Tomcat will not reload the webapp. Could
this be the behavior you are experiencing?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkil2ZcACgkQ9CaO5/Lv0PCerACfb3GTPDWMECHz6XWmOAekWdPb
UK0An1cwuOxVKTh9NgU1ydJJcMJ0xwur
=/13/
-----END PGP SIGNATURE-----

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