Hi,
I recently ran into an issue deploying Nexus on Glassfish. (See my
blog post for details [1])
Nexus uses Slf4J's SLF4JBridgeHandler to redirect all Java Logging to
SLF4J. That combined with Glassfish's LoggingOutputStream causes an
infinite logging loop that eventually ends with a StackOverflowError.
While I don't feel it's right to say that this is a bug in either
Glassfish, SLF4J or Nexus, I would still like the Glassfish community
to be aware of the issue. Perhaps there's room for a warning somewhere
in the documentation.
A more fancy solution could be to use a ThreadLocal to keep track of
the stack depth of LoggingOutputStream methods and throw a more
meaningful exception if a loop is detected.
If you'd like to add a note to the docs, here's something to get you started:
"Glassfish captures any output to System.out and System.err and
redirect this output to the Java Logging API. Please be aware that
installing a logging handler in the Java Logging API which prints back
to System.out or System.err might cause logging to loop until a
StackOverflowError occurs."
It would be interesting to hear what the Glassfish community thinks is
the best way to solve or mediate this issue.
Looking forward to hearing your thoughts,
Eirik.
[1]
http://simplericity.com/2009/01/02/1230894176938.html