Conflicts between log4j libraries

Hello everyone,

I was looking for a solution on google without any success and I decide to post it here. I want to import a library which is a jar (JmDNS) . This library has already a dependency with the module org.apache.log4j which is imported as well as stub. MPS internally use also log4j for logging. Now, when i want to write "message warn "something" " , I got this message: 

java.lang.LinkageError: loader constraint violation: when resolving method "jetbrains.mps.baseLanguage.logging.runtime.model.LoggingRuntime.logMsgView(Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Throwable;Lorg/jetbrains/mps/openapi/project/Project;)V" the class loader (instance of jetbrains/mps/classloading/ModuleClassLoader) of the current class, FishDeviceTools/plugin/DetectFishDevices_Action$1$2, and the class loader (instance of jetbrains/mps/classloading/ModuleClassLoader) for the method's defining class, jetbrains/mps/baseLanguage/logging/runtime/model/LoggingRuntime, have different Class objects for the type org/apache/log4j/Level used in the signature

I don'n know how to solve the conflicts. If somebody know I will be grateful.

Thanks in advance,

Bogdan.  

 

4 comments

Could you please elaborate what's 'module org.apache.log4j' and where it comes from. I assume there's a solution with JmDNS jar listed under 'additional Java classpath' and likely the same jar is exposed as java classes stub so that your action code could reference it.

When do you get the error and what's MPS version you're using?

0

MPS version is 3.3 and JmDNS version is 3.5.4. Basically, MPS has log4j and JmDNS also, then when i write message warn "output" i got that error. 'module org.apache.log4j' comes from JmDNS.

0

MPS 3.3 is way too old to give any reasonable advice. Nevertheless, to solve the issue, we have to make sure log4j from jmdns is not loaded. I assume it's a separate jar next to the one of jmdns. Could you just remove it, so that jmdns uses log4j that comes with MPS? Perhaps, you'll need to add a dependency to solution that exposes jmdns, with a target of MPS.Core stub solution (perhaps, it's MPS.IDEA - you need the one that exposes log4j stub classes). That dependency would make sure classloader of jmdns can access log4j classes.

0

Removing log4j from my jar and adding MPS.IDEA dependency solved the issue. Thanks ! 

0

Please sign in to leave a comment.