tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose Rojas <ricosre...@gmail.com>
Subject Re: Tomcat 7 Embedded and context/class reloading
Date Sat, 04 Aug 2012 14:13:13 GMT
>
> Hello,

I'm using Tomcat 7 embedded mode in my app.  I've had a difficult time
figuring out how to actually reload the context using WatchedResources and
class reloading from WEB-INF/classes/.

What I've noticed is that using the Tomcat class addWebApp() utility
function does not trigger WatchedResource to work.  I've tried providing
the context.xml directly via Context.setConfigFile() but that will not work.

I scoured the Tomcat Catalina code and found that it only triggers this
path if HostConfig gets set up so I've opted to make it function this way.

The second issue I encountered is surprising.  It appears that class
reloading for classes WEB-INF/classes/ does not appear to be working as
expected.  Classes within WEB-INF/lib/ jar files do reload on a context
reload.  However the classes within WEB-INF/classes do not automatically
reload it appears.  What I discovered is that you have to forcefully add
these classes to the search path by calling
WebappClassLoader.findResource(), then call WeappClassLoader.findClass() to
cache them.  If these are missing it appears to me that any dynamic changes
to classes in the folder will not trigger a reload or the new classes won't
be loaded even when using WebappClassLoader.loadClass().  I believe this
issue is not related to embedded Tomcat and will affect normal tomcat as
well.

I managed to workaround these issue, but I'm wondering if there's some
assumptions I'm missing to make reloading work 'out of the box' with the
standard WebappClassLoader.

Has anyone encountered this behavior?

Thanks for the help.

-Jose

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message