overstory / marklogic-intellij-plugin

Plugin to support XQuery + MarkLogic debugging in Intellij Idea
Apache License 2.0
12 stars 2 forks source link

Debugger errors out when log4j is included in project dependencies #45

Closed cschlegelmilch closed 6 years ago

cschlegelmilch commented 7 years ago

Here is the error:

Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/or/RendererMap at org.apache.log4j.Hierarchy.(Hierarchy.java:97) at org.apache.log4j.LogManager.(LogManager.java:82) at org.slf4j.impl.Log4jLoggerFactory.(Log4jLoggerFactory.java:66) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383) at org.intellij.xquery.runner.rt.debugger.marklogic.MarkLogicDebuggerApp.(MarkLogicDebuggerApp.java:46) at org.intellij.xquery.runner.rt.vendor.marklogic.MarklogicRunnerAppFactory.getInstance(MarklogicRunnerAppFactory.java:36) at org.intellij.xquery.runner.rt.XQueryRunnerAppFactory.getInstance(XQueryRunnerAppFactory.java:25) at org.intellij.xquery.runner.rt.XQueryRunnerApp.runConfigForOutputStream(XQueryRunnerApp.java:29) at org.intellij.xquery.runner.rt.XQueryRunnerApp.main(XQueryRunnerApp.java:25) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.or.RendererMap at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 15 more Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/or/RendererMap at org.apache.log4j.Hierarchy.(Hierarchy.java:97) at org.apache.log4j.LogManager.(LogManager.java:82) at org.slf4j.impl.Log4jLoggerFactory.(Log4jLoggerFactory.java:66) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383) at org.intellij.xquery.runner.rt.debugger.marklogic.MarkLogicDebuggerApp.(MarkLogicDebuggerApp.java:46) at org.intellij.xquery.runner.rt.vendor.marklogic.MarklogicRunnerAppFactory.getInstance(MarklogicRunnerAppFactory.java:36) at org.intellij.xquery.runner.rt.XQueryRunnerAppFactory.getInstance(XQueryRunnerAppFactory.java:25) at org.intellij.xquery.runner.rt.XQueryRunnerApp.runConfigForOutputStream(XQueryRunnerApp.java:29) at org.intellij.xquery.runner.rt.XQueryRunnerApp.main(XQueryRunnerApp.java:25) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.or.RendererMap at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 15 more

RobertSzkutak commented 7 years ago

I see a similar (same?) issue with log4j. I'm using IntelliJ 2017.2.1 Community Edition on Windows. I can "run" a query just fine. However when I try to "debug" it all I receive is this message in the console:

log4j:WARN No appenders could be found for logger (org.intellij.xquery.runner.rt.debugger.marklogic.MarkLogicDebuggerApp).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Process finished with exit code 1

I tried a handful of things but either faced the above error or this one.

ronhitchens commented 6 years ago

This was a side effect of the way the debugger works. It forks out a separate JVM to run the code in debug mode. It has to take steps to include any additional jars needed by the debugger connector in the external JVM. This can lead to conflicts if the jars are also used in the project. I tried filtering out jars that are already in the project, but couldn't get it to work reliably. In v1.0, log4j has been removed entirely and plain println's are now used. Most of the logging is only for debugger development anyway.