Bug 55656 - Server ClassLoader not used for Server creation
Server ClassLoader not used for Server creation
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
PC All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2013-10-16 09:56 UTC by Roberto Benedetti
Modified: 2013-10-17 15:29 UTC (History)
0 users

proposed patch (1.25 KB, text/plain)
2013-10-16 09:56 UTC, Roberto Benedetti

Note You need to log in before you can comment on or make changes to this bug.
Description Roberto Benedetti 2013-10-16 09:56:54 UTC
Created attachment 30931 [details]
proposed patch

When configuring server.loader in catalina.properties with libraries containing valves or realms and their dependencies, if those classes are set in server.xml a CNFE is thrown.

The reason is Digester using StandardServer's ClassLoader and not context ClassLoader.
Comment 1 Christopher Schultz 2013-10-16 13:45:56 UTC
Did you mean "context" instead of "server" in one of those cases in the description?
Comment 2 Roberto Benedetti 2013-10-16 14:43:25 UTC
(In reply to Christopher Schultz from comment #1)
> Did you mean "context" instead of "server" in one of those cases in the
> description?

Before instantiating and configuring the server, the "server" loader is set as the "context" loader: Thread.currentThread().setContextClassLoader(catalinaLoader) in Bootstrap class.

During startup "server" and "context" loader are the same.

The Digester created to configure the server is instructed to use the loader of StandardServer class, but that loader is the "common" loader not the "server" loader.
Comment 3 Mark Thomas 2013-10-17 15:29:04 UTC
Thanks for the patch.

The report makes sense and the patch looks good to me.

It has been applied to 8.0.x for 8.0.0-RC6 onwards and 7.0.x for 7.0.48 onwards.

Thanks again.