ClassLoader error when using own log4j

Hi guys,

my IntellIJ plugin depends on a "core" module that brings its own log4j library. The "core" cannot use the IDEA SDK, because it is supposed to be IDE-independent (Eclipse + IntelliJ). My library setup:

  * log4j.jar is part of the dependencies of the "core" module with "export" checked
  * my plugin has the "core" module as depency, to get all its exported dependencies
  * I removed the log4j.jar from the IDEA SDK classpath in order to avoid version conflicts

Now when I fire up my plugin, I get this error:

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [PluginClassLoader[de.fu_berlin.inf.dpp.intellij.1, 10.1.1]] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [com.intellij.util.lang.UrlClassLoader@44d03877].
log4j:ERROR Could not instantiate appender named "SarosConsoleAppender".


What is going wrong?

Regards,
Holger

4 comments
Comment actions Permalink

That looks to me like you're getting a conflict between the version of log4j provided by IntelliJ and your version. Why do you have to supply your own version? Couldn't you just exclude your version from your plugin jar and get it to use the version provided by the platform?

0
Comment actions Permalink

Yeah, I guess that's the source. The "core" module has to use its own version, because it has no dependency on the IDEA SDK.

my module structure is as follows:

log4j.jar -- IDEA SDK <-- depends on -- | intellij plugin | --- depends on --> core -- log4j.jar

I dont see how I can exclude the core.log4j.jar from the core module, because then I get compile errors (because it does not use an IDEA SDK). Shouldnt it work the other way around, that I do not use the IDEA SDK log4j?

0
Comment actions Permalink

For the core module, could you give the log4j library provided scope? Then it would be available for compilation but would not be packaged.


0
Comment actions Permalink

Nice! that fixed it :-)

0

Please sign in to leave a comment.