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 15:45:38 UTC

Problems running TC 7 with Log4J 1.2 and Java 11

Hi all,

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.

Any ideas?

Regards,

Rainer

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


Re: Problems running TC 7 with Log4J 1.2 and Java 11

Posted by Romain Manni-Bucau <rm...@gmail.com>.
You mean the config in server and libs in common? Only tested with all in
the same loader.

Le jeu. 22 nov. 2018 19:52, Rainer Jung <ra...@kippdata.de> a écrit :

> Hi Romain, hi all,
>
> are you sure you tried i as I described? Namely loading the config via a
> server.loader path property newly defined in conf/catalina.properties?
> And of course I was using the juli and juli-adapters jar from the 7.0.92
> extras download.
>
> I have another detail to report: it starts working even with Java 11 and
> using the server loader, when i place the log4j.jar and the
> juli-adapters.jar into the server loader instead of the common loader.
> That's interesting, because it was not needed until and including Java
> 10. It worked there by just putting the config into the server loader
> and keeping the log4j and juli-adapters jar in the common loader.
>
> It seems that either for some reason the server loader is no longer
> parent of the common loader or the getResource() call changed behavior
> w.r.t. class loader hierarchies and delegation.
>
> Will debug further.
>
> Regards,
>
> Rainer
>
> Am 22.11.2018 um 18:31 schrieb Romain Manni-Bucau:
> > Hi Rainer,
> >
> > You are right, missed it was set OOTB.
> >
> > BTW, just tested on tomcat 7.0.92 with the log4j (v1.2.17) and its
> > adapter (of the 8.0.53) and java 11.0.1+13-LTS and it works for me
> > (base=home in my test).
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> | Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github
> > <https://github.com/rmannibucau> | LinkedIn
> > <https://www.linkedin.com/in/rmannibucau> | Book
> > <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >
> >
> > Le jeu. 22 nov. 2018 à 17:40, Rainer Jung <rainer.jung@kippdata.de
> > <ma...@kippdata.de>> a écrit :
> >
> >     Hi Romain,
> >
> >     Am 22.11.2018 um 16:53 schrieb Romain Manni-Bucau:
> >      > Hi Rainer,
> >      >
> >      > did you open some java.base modules? like
> >
> >     No, just the add-opens that we ship in our catalina.sh.
> >
> >      > --add-opens java.base/java.lang=log4j
> >      >
> >      > (not sure this is the one to open but I guess you can debug and
> >     identified
> >      > missing open this way - debugging
> >     java.lang.Module#isOpen(java.lang.String)
> >      > for instance)
> >
> >     I hoped to find a more definitive answer here, not needing to debug
> >     into
> >     code.
> >
> >     Note this is Log4j 1.2, not 2. So not sure why there should be a
> module
> >     "log4j". And if log4j would instead be part of the unnamed module,
> then
> >     the already existing --add-opens=java.base/java.lang=ALL-UNNAMED
> would
> >     be the corrected line for what you suggest. But as said: that one is
> >     already one of the three add-opens TC contains in catalina.sh by
> >     default.
> >
> >     Regards,
> >
> >     Rainer
> >
> >      > Romain Manni-Bucau
> >      > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >      > <https://rmannibucau.metawerx.net/> | Old Blog
> >      > <http://rmannibucau.wordpress.com> | Github
> >     <https://github.com/rmannibucau> |
> >      > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> >      >
> >     <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >      >
> >      >
> >      > Le jeu. 22 nov. 2018 à 16:45, Rainer Jung
> >     <rainer.jung@kippdata.de <ma...@kippdata.de>> a
> >      > écrit :
> >      >
> >      >> Hi all,
> >      >>
> >      >> 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.
> >      >>
> >      >> Any ideas?
> >      >>
> >      >> Regards,
> >      >>
> >      >> Rainer
>

Re: Problems running TC 7 with Log4J 1.2 and Java 11

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Romain, hi all,

are you sure you tried i as I described? Namely loading the config via a 
server.loader path property newly defined in conf/catalina.properties? 
And of course I was using the juli and juli-adapters jar from the 7.0.92 
extras download.

I have another detail to report: it starts working even with Java 11 and 
using the server loader, when i place the log4j.jar and the 
juli-adapters.jar into the server loader instead of the common loader. 
That's interesting, because it was not needed until and including Java 
10. It worked there by just putting the config into the server loader 
and keeping the log4j and juli-adapters jar in the common loader.

It seems that either for some reason the server loader is no longer 
parent of the common loader or the getResource() call changed behavior 
w.r.t. class loader hierarchies and delegation.

Will debug further.

Regards,

Rainer

Am 22.11.2018 um 18:31 schrieb Romain Manni-Bucau:
> Hi Rainer,
> 
> You are right, missed it was set OOTB.
> 
> BTW, just tested on tomcat 7.0.92 with the log4j (v1.2.17) and its 
> adapter (of the 8.0.53) and java 11.0.1+13-LTS and it works for me 
> (base=home in my test).
> 
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> | Blog 
> <https://rmannibucau.metawerx.net/> | Old Blog 
> <http://rmannibucau.wordpress.com> | Github 
> <https://github.com/rmannibucau> | LinkedIn 
> <https://www.linkedin.com/in/rmannibucau> | Book 
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
> 
> 
> Le jeu. 22 nov. 2018 à 17:40, Rainer Jung <rainer.jung@kippdata.de 
> <ma...@kippdata.de>> a écrit :
> 
>     Hi Romain,
> 
>     Am 22.11.2018 um 16:53 schrieb Romain Manni-Bucau:
>      > Hi Rainer,
>      >
>      > did you open some java.base modules? like
> 
>     No, just the add-opens that we ship in our catalina.sh.
> 
>      > --add-opens java.base/java.lang=log4j
>      >
>      > (not sure this is the one to open but I guess you can debug and
>     identified
>      > missing open this way - debugging
>     java.lang.Module#isOpen(java.lang.String)
>      > for instance)
> 
>     I hoped to find a more definitive answer here, not needing to debug
>     into
>     code.
> 
>     Note this is Log4j 1.2, not 2. So not sure why there should be a module
>     "log4j". And if log4j would instead be part of the unnamed module, then
>     the already existing --add-opens=java.base/java.lang=ALL-UNNAMED would
>     be the corrected line for what you suggest. But as said: that one is
>     already one of the three add-opens TC contains in catalina.sh by
>     default.
> 
>     Regards,
> 
>     Rainer
> 
>      > Romain Manni-Bucau
>      > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>      > <https://rmannibucau.metawerx.net/> | Old Blog
>      > <http://rmannibucau.wordpress.com> | Github
>     <https://github.com/rmannibucau> |
>      > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
>      >
>     <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>      >
>      >
>      > Le jeu. 22 nov. 2018 à 16:45, Rainer Jung
>     <rainer.jung@kippdata.de <ma...@kippdata.de>> a
>      > écrit :
>      >
>      >> Hi all,
>      >>
>      >> 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.
>      >>
>      >> Any ideas?
>      >>
>      >> Regards,
>      >>
>      >> Rainer

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


Re: Problems running TC 7 with Log4J 1.2 and Java 11

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Rainer,

You are right, missed it was set OOTB.

BTW, just tested on tomcat 7.0.92 with the log4j (v1.2.17) and its adapter
(of the 8.0.53) and java 11.0.1+13-LTS and it works for me (base=home in my
test).

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le jeu. 22 nov. 2018 à 17:40, Rainer Jung <ra...@kippdata.de> a
écrit :

> Hi Romain,
>
> Am 22.11.2018 um 16:53 schrieb Romain Manni-Bucau:
> > Hi Rainer,
> >
> > did you open some java.base modules? like
>
> No, just the add-opens that we ship in our catalina.sh.
>
> > --add-opens java.base/java.lang=log4j
> >
> > (not sure this is the one to open but I guess you can debug and
> identified
> > missing open this way - debugging
> java.lang.Module#isOpen(java.lang.String)
> > for instance)
>
> I hoped to find a more definitive answer here, not needing to debug into
> code.
>
> Note this is Log4j 1.2, not 2. So not sure why there should be a module
> "log4j". And if log4j would instead be part of the unnamed module, then
> the already existing --add-opens=java.base/java.lang=ALL-UNNAMED would
> be the corrected line for what you suggest. But as said: that one is
> already one of the three add-opens TC contains in catalina.sh by default.
>
> Regards,
>
> Rainer
>
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
> >
> >
> > Le jeu. 22 nov. 2018 à 16:45, Rainer Jung <ra...@kippdata.de> a
> > écrit :
> >
> >> Hi all,
> >>
> >> 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.
> >>
> >> Any ideas?
> >>
> >> Regards,
> >>
> >> Rainer
>

Re: Problems running TC 7 with Log4J 1.2 and Java 11

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Romain,

Am 22.11.2018 um 16:53 schrieb Romain Manni-Bucau:
> Hi Rainer,
> 
> did you open some java.base modules? like

No, just the add-opens that we ship in our catalina.sh.

> --add-opens java.base/java.lang=log4j
> 
> (not sure this is the one to open but I guess you can debug and identified
> missing open this way - debugging java.lang.Module#isOpen(java.lang.String)
> for instance)

I hoped to find a more definitive answer here, not needing to debug into 
code.

Note this is Log4j 1.2, not 2. So not sure why there should be a module 
"log4j". And if log4j would instead be part of the unnamed module, then 
the already existing --add-opens=java.base/java.lang=ALL-UNNAMED would 
be the corrected line for what you suggest. But as said: that one is 
already one of the three add-opens TC contains in catalina.sh by default.

Regards,

Rainer

> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
> 
> 
> Le jeu. 22 nov. 2018 à 16:45, Rainer Jung <ra...@kippdata.de> a
> écrit :
> 
>> Hi all,
>>
>> 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.
>>
>> Any ideas?
>>
>> Regards,
>>
>> Rainer

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


Re: Problems running TC 7 with Log4J 1.2 and Java 11

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Rainer,

did you open some java.base modules? like

--add-opens java.base/java.lang=log4j

(not sure this is the one to open but I guess you can debug and identified
missing open this way - debugging java.lang.Module#isOpen(java.lang.String)
for instance)

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le jeu. 22 nov. 2018 à 16:45, Rainer Jung <ra...@kippdata.de> a
écrit :

> Hi all,
>
> 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.
>
> Any ideas?
>
> Regards,
>
> Rainer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

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

Posted by Rainer Jung <ra...@kippdata.de>.
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