You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rainer Jung <ra...@kippdata.de> on 2018/11/22 23:26:40 UTC

[Solved] Problems running TC 7 with Log4J 1.2 and Java 11

Am 22.11.2018 um 16:45 schrieb Rainer Jung:
> I have a problem running TC 7.0.92 with Log4J 1.2.17 and Java 11 when 
> trying to load the config from ${catalina.base}/somedir/log4j.properties 
> via server.loader=${catalina.base}/somedir in conf/catalina.properties.
> 
> It works with Java 9 and 10 and it also works when using the 
> common.loader instead of server.loader. Setting -Dlog4j.debug shows, 
> that log4j tries to load the files via the class loader but isn't able to:
> 
> Trying to find [log4j.xml] using java.net.URLClassLoader@c267ef4 class 
> loader.
> Trying to find [log4j.xml] using ClassLoader.getSystemResource().
> Trying to find [log4j.properties] using java.net.URLClassLoader@c267ef4 
> class loader.
> Trying to find [log4j.properties] using ClassLoader.getSystemResource().
> Could not find resource: [null].
> log4j:WARN No appenders could be found for logger 
> (org.apache.catalina.startup.Catalina).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for 
> more info.
> 
> I suspect it might have to do with some module system change in JAVA 11, 
> but I found nothing obvious. Adding "--illegal-access=debug" doesn't 
> produce any output.
> 
> I'm using the log4j juli plus adapters. No problems using log4j 1.2 
> inside webapps directly.

It turns out it is a version detection bug in log4j 1.2. They read the 
"java.version" system property to check, whether the JVM is Java 1 
(sic!). If so, they do not try to use the TCCL to look up the config 
file, only the class loader that defines the class that looks it up.

In my Tomcat case, it would be the TCCL (system aka catalina loader) 
that would find it, but not the class defining class loader (common loader).

My Java 10 had 10.0.2 as "java.version", but Java 11 (no patch yet 
installed) had a plain "11" and if "java.version" contains no dot, then 
Log4J 1.2 thinks it is Java 1 (plus some more erroneous assumptions).

So no Java bug, no TC bug, just a Log4J 1.2 annoyance that should no 
longer be observable once I have installed 11.0.1.

Thanks and regards,

Rainer

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