Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinkageError with Jenkins on WebLogic

I have Jenkins 1.613 running on WebLogic 12c, and also on JBoss EAP 6.3. I have managed to get the Jenkins email-ext plugin working on JBoss. However, whenever I use tokens such as $PROJECT_NAME, the email-ext plugin fails on WebLogic (works perfectly fine on JBoss, I should emphasise again).

I get the following stacktrace which seems to indicate some problem with the tokenmacro plugin.

java.lang.LinkageError: loader constraint violation: when resolving method
"com.google.common.collect.Multimaps.newListMultimap( java/util/Map; com/google/common/base/Supplier;) com/google/common/collect/ListMultimap;"

the class loader (instance of hudson/ClassicPluginStrategy$AntClassLoader2) of the current class, org/jenkinsci/plugins/tokenmacro/Tokenizer,

and the class loader (instance of sun/misc/Launcher$AppClassLoader) for resolved class, com/google/common/collect/Multimaps,

have different Class objects for the type ap; com/google/common/base/Supplier;) com/google/common/collect/ListMultimap; used in signature

at org.jenkinsci.plugins.tokenmacro.Tokenizer.find(Tokenizer.java:109)
at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:167)
at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:233)
at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:71)
at hudson.plugins.emailext.ExtendedEmailPublisher.setSubject(ExtendedEmailPublisher.java:659)

Questions:

  1. Based on my understanding of this trace, the problem is that there are conflicting copies of the Multimaps class that have been loaded? Is that right?
  2. Why would there be multiple classloaders (AntClassLoader2 and AppClassLoader) involved? Shouldn't it be the case that, once a classloader finds the required class, it simply "returns" that class, and it delegates classloading to parent classloaders only when it does not find the class?
  3. Why does my setup work in JBoss but not in WebLogic?
  4. What can be done to resolve this problem? I have tried placing Guava 11 in the WEB-INF of the tokenmacro plugin directory, but it doesn't help. I've also tried the same with Guava 13.

Additional information that might be of use:

  • Token Macro Plugin version installed is 1.10
  • Email Extension Plugin version installed is 2.40.5
  • In my jenkins.war, I have a weblogic.xml file where wls:prefer-web-inf-classes is set to true.
like image 608
Jesse Lynn Avatar asked Jul 14 '15 08:07

Jesse Lynn


2 Answers

1.) I would assume the same.

2.a (multiple classloaders): There are special classloaders in application containers like JBoss. They serve to separate classes in different applications. You should be able to use any version of a class in your application independant of the version used in a different application.

Therefore two classes are considered different if they have the same name but different classloaders.

Problems arise where two applications get "in contact" or where classes are provided by the container. I would guess that the problem is around Guava being provided by WebLogic.

Additionally, Jenkins is a kind of application container itself, it must separate different plugins, therefore the AntClassLoader2.

2b (Classloader delegation): Usually it's just the other way round: always ask the parent classloader, if it cannot find the class, try to find it yourself. But the whole story is much more complex (to get an idea see https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html, maybe there is some similar documentation for WebLogic, too).

3) As a first guess I would check if WebLogic (as your instance is configured) provides Guava.

4) I would try to isolate the problem and make it reproducable writing a small webapp that uses Supplier. Maybe I would search and read documentation about how classloading is handled in WebLogic.

like image 87
Gustave Avatar answered Oct 19 '22 23:10

Gustave


I am able to test the email ext tempate but not able to send.

like image 30
Shalin Avatar answered Oct 19 '22 23:10

Shalin