-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Austin,

On 3/23/15 2:54 PM, Austin Jones wrote:
> Hi Chris,
> 
>> If MyClass had been loaded at initialization time (like your
>> sample code shows), it should not have needed to be loaded back
>> off the disk for shutdown.
> 
> In my first example, the ClassNotFoundError is thrown when
> enabled=false. When enabled=true, the error doesn't occur.

When you say enabled=true, you mean that's what's showing in the
Manager's web interface?

>> Is it possible that MyClass is referencing another class 
>> (MyOtherClass) during shutdown that was never referenced during
>> startup?
> 
> In my production code, yes, that is the issue.

Okay. IIRC, during ServletContextListener.contextDestroyed, the
WebappClassLoader should be fully-functional. That is, it shouldn't
have complained about anything.

A reload() operation should be first stopping everything, then
disabling and discarding the WebappClassLoader for the "old" web
application, then creating a new WebappClassLoader and launching the
"new" copy of the web application using that new WebappClassLoader.

The "new" WebappClassLoader shouldn't even be involved, yet, since the
shutdown is evidently not completing successfully, so the reload never
actually gets to the "load" part.

It's possible that Tomcat's reload process first notifies the
WebappClassLoader that it shouldn't load any new classes during
shutdown, but that sounds like it would be a recipe for disaster --
the kind of disaster that you are experiencing, here.

> I actually have reworked my app's top-level initialization layer to
> preload classes on startup.  I am considering preloading all
> classes in WEB-INF/classes at server startup.  Unfortunately, my
> init layer needs to call into code deeper in the application, which
> may call into bundled JARs (WEB-INF/lib).  Including JARs, that
> would be a lot of code to preload.

It also shouldn't be necessary. I think something else weird might be
going on.

When you do the reload(), are you shutting-down a properly-running web
application, or one that failed to load properly in the first place?

Are there any other log messages in either your application's log, the
localhost_*.log, or catalina.out that come *before* this
ClassNotFoundException?

In your original message, did you post the full and complete stack trace?

Taking a look at Tomcat 8 trunk, this code has undergone a large
refactoring since 8.0.12 so the line numbers aren't correct relative
to your stack trace. I looked in 8.0.12 and the line in question
(WebappClassLoader.java:1320) is at the end of the loadClass method,
when all options for loading the class have been exhausted. It just
gives up and says "sorry, I can't find the class".

In this case, I would expect that the class is actually missing. Are
you sure it's there? Where is it located?

At first I was thinking that WCL was objecting to loading the class,
but it's not: it's actually not finding it. Now, Tomcat 8 uses a more
complicated resource-loading framework than previous Tomcats, and it's
possible that the resource-loading framework is being taken down
earlier than your code is running, which would make certain classes
/libraries inaccessible. I haven't read enough code to know if that's
the case or not. IMO it shouldn't be the case, and probably isn't
because the smarter Tomcat devs tend to think about things like that
before coding them ;)

After all that...

Would you be willing to try the newly-minted 8.0.21, or 8.0.20, to see
if it makes a difference?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJVEwfwAAoJEBzwKT+lPKRYlD8P/0MaHgu+5Q+VwehiP8BxMQ3g
JNNtu/+QQb2Rgzi3SjYwV8JzS3qmvEqcT0Fq+0bA6QOOL0Ae2IbrY/PVCWMz0Riz
2QjTsPG28SrmzsgVh/EiNxVnFBx/OzkQEfcvnjwQjYMgzH42mri3J2bk9MJ8i/mw
MwKEADFVJMwmadtb1ctl1QV2Kb0aK2dJm6rZ7O2Hyd/9YOuASxrtB7aB9UVAbqZ5
ZSfn70JIcCDgCxDbsg9nFmDxEewCj4V5V2mjqq73V6ZfPszzjZNmvWeZnqJb/7Et
fpw62W+MuRdsYhoidbwNaiXF1cDOneUi5l/Ci5UEZwP4YtAt3LnFaFnKQIVIEyl0
7UbCdczXF3EofrhhWgChg89UvmIIODfGLkvZeErXFfJveHQwK180ObD1iocIBLDH
cOnFGcJwm8P0/e/pRbzJsXfdwaCBSM2EGYLyhKHSJouD+YGUKIh1rVCvoZlqoRzs
+sZW1aOW6AKveU1qr2ugu3ZkgLxUKttDtCbecdnyzb5OdTpV4aWiJlqbiHCv8zd5
wFRFdB5jvDc8UfQGFELMBzhJo6q1YK9hgMbQNKXYqNT3+nKr9O+GhZGF96yieiT7
0ow4x4a31OHbieqhMNpQQ6gMtcV4ylwClLoqdKdIHV1xcEXaRKJAho36V/0RUkhE
EtS3voWtAVpfDUeZ5ijh
=IG7C
-----END PGP SIGNATURE-----

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

Reply via email to