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.

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.

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.

On Mon, Mar 23, 2015 at 7:19 AM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Austin,
>
> On 3/22/15 10:11 PM, Austin Jones wrote:
> > After a bit of debugging, I found the issue.  The stack traces
> > below are on 8.0.12-src.
> >
> > The bug occurs at this stack:
> >
> >> StandardContext.reload() line: 3779
> >> HostConfig.reload(HostConfig$DeployedApplication) line: 1306
> >> HostConfig.checkResources(HostConfig$DeployedApplication) line:
> >> 1238 HostConfig.check(String) line: 1493
> >
> >
> > HostConfig.checkResources(DeployedApplication) runs through the
> > branch:
> >
> >> if (app.hasDescriptor && resource.getName().toLowerCase(
> >> Locale.ENGLISH).endsWith(".war")) { ... }
> >
> >
> > It calls ExpandWar.delete( docBaseFile ), which is the unpacked
> > webapp directory.
> >
> > Then, checkResources calls reload(app) - which invokes the context
> > listener.
> >
> > The ClassLoader eventually gets down to this stack:
> >
> >> DirResourceSet.getResource(String) line: 100
> >
> > StandardRoot.getResourceInternal(String, boolean) line: 280
> >> Cache.getResource(String, boolean) line: 65
> >> StandardRoot.getResource(String, boolean, boolean) line: 216
> >> StandardRoot.getClassLoaderResource(String) line: 225
> >> WebappClassLoader.findResourceInternal(String, String) line:
> >> 2556 WebappClassLoader.findClassInternal(String) line: 2410
> >> WebappClassLoader.findClass(String) line: 880
> >> WebappClassLoader.loadClass(String, boolean) line: 1290
> >> WebappClassLoader.loadClass(String) line: 1173
> >> TestcaseContextListener.contextDestroyed(ServletContextEvent)
> >> line: 23 StandardContext.listenerStop() line: 4792
> >> StandardContext.stopInternal() line: 5392
> >> StandardContext(LifecycleBase).stop() line: 232
> >> StandardContext.reload() line: 3768
> >> HostConfig.reload(HostConfig$DeployedApplication) line: 1306
> >> HostConfig.checkResources(HostConfig$DeployedApplication) line:
> >> 1238 HostConfig.check(String) line: 1493
> >
> >
> > Unfortunately, checkResources just deleted the base directory.
> > The ClassLoader is looking for
> > /WEB-INF/classes/com/avadyne/ThisClassNotFound.class, but that path
> > no longer exists.  Most of the functions in the stack return null,
> > and findClassInternal(String) throws the ClassNotFoundError at line
> > 906.
> >
> > OK, how should this be fixed?  Should the ClassLoader fall back to
> > the compressed WAR?  Should the DocBase be deleted after the
> > context is stopped?
>
> 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.
>
> Is it possible that MyClass is referencing another class
> (MyOtherClass) during shutdown that was never referenced during startup?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
>
> iQIcBAEBCAAGBQJVECDbAAoJEBzwKT+lPKRYWvUP/1EI5C6OzLOpo7kfknDZuoOK
> bjZiGsVjijiIbaFvVIJnhzXuwE6AW+xGeYOk+VlhxmnkPE2CFk/IH4ACRhN8unqr
> THWn7XS6OqFP2pixIkZoD0JPqlGXJmOSuJuHm/9LhsxCemMV0ZiZo9pFbQrgDDyt
> gpHGC7JNRPzLuf6b9xXIKdsDaKIPgeUCUF4TFlkD8t88214hVGszi8Iqa8oUuYuM
> VKHlufsmzQajjHRkNEZvc8yMOhCP/LJdhsX4GWjW1zcun/4fLHFWKU5eMQkHb5CK
> VXCS/XsTw8vnuTbI/CQ5QiloOWeong6uK1RtDoKg73quvBNXdjn8kApV01nPMNnr
> HWaCZJvtlcmjmfDDnI6NJilTR3y4K1zHR0uYuE6EtqxT4s0lkuBq5752Bq9KcNSo
> WzVKtxsxDkl+Kx60iqHFEu4/VJF4FahB4DHNOwnHXDOGrdpSGj4JrN4PrAd79ZEI
> 5dZEhg4bozEpoenXQ9Qs5KRKNUzJpC9ZIems5OgbFpHjiHqizc+dR9/kH9DdaVk+
> AcLI3JtCO5OBrxLyJ1qqnrsIpREJ/qnLpvO4+iX/ImOX+eCTOEmdUoDecjZDeUeP
> dMarqycbwLLZKABseAIRA8ut2XnpAaGf0NLPI5SWdMDp2uPbSG1+PIIjxeUFeLX5
> fQ6a+Q79kJAbgnwzrCvA
> =g8G/
> -----END PGP SIGNATURE-----
>

Reply via email to