You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Wolverton <da...@vodori.com> on 2011/07/27 16:20:06 UTC

Updating JAR META-INF/resources at runtime

I'm running Tomcat 7.0.19 with IntelliJ IDEA IDE. I'm using the new Servlet
3.0 feature that allows webapp resources to be served from within JARs'
META-INF/resources directory. This technique is working fine, however I
would like to be able to "hot swap" these resources at runtime in a local
development environment using my IDE. That is not working.

In my scenario, I have two artifacts in IDEA. One is a webapp that produces
a WAR (I'm deploying this as an exploded war to tomcat). The other is a JAR
with some JavaScript / CSS / HTML and JSP resources. The webapp includes the
JAR. When IDEA deploys the webapp it compiles creates the JAR from the
second artifact and plops it in the exploded webapp's lib folder. It then
starts up tomcat and points it to the exploded webapp folder. This works
perfectly. Then, while tomcat is running, I make a change to one of the
resources in the JAR and tell IDEA to update classes and resources. I can
see on disk that IDEA puts a new version of the JAR in the libs folder. The
JAR has an new modified date. If I unzip the JAR, I can see that it contains
my changes. However tomcat is still serving up the old version of the file.

The same thing happens whether I update a file or add a new file. The
behavior is also the same for both static files and JSPs.

Note that updates work fine for resources in the webapps root directory,
it's only the resources inside JARs that don't reload. Also note that the
updates do come through fine once I restart tomcat or reload the webapp;
however I would very much like to avoid having to do that.

Is this a Tomcat bug, missing feature, or is there something IDEA is doing
incorrectly?

Thanks.

--

David Wolverton | Vodori Inc | david.wolverton@vodori.com | (w) 312.324.3963
| (c) 773.571.3750

Re: Updating JAR META-INF/resources at runtime

Posted by Pid <pi...@pidster.com>.
On 28/07/2011 08:31, Pid wrote:
> On 27/07/2011 17:06, David Wolverton wrote:
>> Thanks Ognjen,
>>
>> Using 'reloadable' does cause the resources to update. However, this is not
>> the solution I am looking for because it does this by reloading the webapp.
> 
> The classloader initialises at loadtime, in order to release resources
> and load new ones, the classloader has to be reinitialised.

Well, kinda.  (That's imprecise, blame a lack of coffee.)


p

> The URLClassLoader has an .addURL() method, but no corresponding
> .removeURL() method, so there's no way to ensure that class
> archive/resource has been released, without entirely replacing the
> classloader.
> 
>> It can take a lot of time for the webapp to restart and cause other side
>> effects, so I would prefer not to have to do this.
>>
>> Anyone have any other insight? Should I file a bugzilla feature request?
> 
> To do what?
> 
> 
> p
> 
> 
> 
> 
> 


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


Re: Updating JAR META-INF/resources at runtime

Posted by Pid <pi...@pidster.com>.
On 27/07/2011 17:06, David Wolverton wrote:
> Thanks Ognjen,
> 
> Using 'reloadable' does cause the resources to update. However, this is not
> the solution I am looking for because it does this by reloading the webapp.

The classloader initialises at loadtime, in order to release resources
and load new ones, the classloader has to be reinitialised.

The URLClassLoader has an .addURL() method, but no corresponding
.removeURL() method, so there's no way to ensure that class
archive/resource has been released, without entirely replacing the
classloader.

> It can take a lot of time for the webapp to restart and cause other side
> effects, so I would prefer not to have to do this.
> 
> Anyone have any other insight? Should I file a bugzilla feature request?

To do what?


p






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


Re: Updating JAR META-INF/resources at runtime

Posted by Mark Thomas <ma...@apache.org>.
On 27/07/2011 17:06, David Wolverton wrote:
> Thanks Ognjen,
> 
> Using 'reloadable' does cause the resources to update. However, this is not
> the solution I am looking for because it does this by reloading the webapp.
> It can take a lot of time for the webapp to restart and cause other side
> effects, so I would prefer not to have to do this.
> 
> Anyone have any other insight? Should I file a bugzilla feature request?

Sure, but be prepared for it to be resolved as WONTFIX if the Tomcat
committers decide that the cost of implementing this feature (code
complexity, performance etc) doesn't outweigh the benefits.

Mark



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


Re: Updating JAR META-INF/resources at runtime

Posted by David Wolverton <da...@vodori.com>.
Thanks Ognjen,

Using 'reloadable' does cause the resources to update. However, this is not
the solution I am looking for because it does this by reloading the webapp.
It can take a lot of time for the webapp to restart and cause other side
effects, so I would prefer not to have to do this.

Anyone have any other insight? Should I file a bugzilla feature request?

Thanks

--

David Wolverton | Vodori Inc | david.wolverton@vodori.com

Re: Updating JAR META-INF/resources at runtime

Posted by Ognjen Blagojevic <og...@gmail.com>.
Hi David,

On 27.7.2011 16:20, David Wolverton wrote:
> I'm running Tomcat 7.0.19 with IntelliJ IDEA IDE. I'm using the new Servlet
> 3.0 feature that allows webapp resources to be served from within JARs'
> META-INF/resources directory. This technique is working fine, however I
> would like to be able to "hot swap" these resources at runtime in a local
> development environment using my IDE. That is not working.

Take a look at the Context parameter 'reloadable' [1]. Is it set to true?

IDEA might insert context information into server.xml (as Eclipse does), 
so check server.xml file first.


-Ognjen


[1] 
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Common_Attributes


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