NoClassDefFoundError: com/google/common/cache/CacheBuilder

4,390 views
Skip to first unread message

David Mata Gorriz

unread,
Jul 18, 2013, 6:24:43 AM7/18/13
to jenkin...@googlegroups.com

 

Hi, everyone.

 

We have a plugin in our company to do some specific tasks. In the last weeks, we had to add guava as a dependency to avoid

 

java.lang.NoClassDefFoundError: com/google/common/cache/CacheBuilder

         at hudson.model.Queue.<init>(Queue.java:188)

         at jenkins.model.Jenkins.<init>(Jenkins.java:764)

         at hudson.model.Hudson.<init>(Hudson.java:81)

         at org.jvnet.hudson.test.HudsonTestCase.newHudson(HudsonTestCase.java:469)

         at org.jvnet.hudson.test.HudsonTestCase.setUp(HudsonTestCase.java:312)

         at junit.framework.TestCase.runBare(TestCase.java:139)

         at org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:290)

         at junit.framework.TestResult$1.protect(TestResult.java:122)

 

Do you know why is that? I think we shouldn’t be required to do it.

Maybe I made a mistake, or some of the plugins I use (artifactory, sonar, svn).

 

Thanks



AVISO DE CONFIDENCIALIDAD
Este correo electrónico y cualquier fichero con el transmitido son confidenciales, contienen información privilegiada y son de conocimiento y uso exclusivo de la persona o entidad a quienes han sido dirigidos. Su contenido no puede ser modificado. En caso de recibir este mensaje por error, le rogamos que informe de inmediato al remitente y proceda a destruir dicho mensaje y cualquier copia que hubiese realizado. Como el correo electrónico puede verse afectado por fallos técnicos u operacionales, no se garantiza su recepción de forma adecuada y puede estar sujeta a retrasos. Cualquier
comunicación que esté supeditada a una fecha u hora pactadas previamente, también deberá ser enviada por correo convencional o fax. El correo electrónico no garantiza la confidencialidad del contenido de los mensajes. Si el destinatario de este mensaje tiene cualquier objeción a la utilización de este medio, deberá ponerse en contacto de inmediato con el remitente. Está estrictamente prohibido el uso, copia o distribución por cualquier medio no autorizado de este mensaje y de cualquier fichero en el contenido.
CONFIDENTIALITY WARNING
This e-mail and any files transmitted with it are confidential and privileged, and are intented solely for the use of the individual or entity to whom they are addressed. Their contents may not be altered. If you are not the intended recipient of this communication please notify the sender and delete and destroy all copies immediately. As e-mail can be subject to operational or technical difficulties, the quality of reception may be affected and it is subject to time delays. Therefore, communications that are subject to deadlines should also be sent by post or fax. Please note that one cannot guarantee the confidentiality of e-mail messages. If the recipient of this message objects to the use of Internet e-mail, please notify the sender immediately. Any unauthorised direct or indirect use, dissemination, distribution or copying of this message is prohibited.

Jesse Glick

unread,
Jul 18, 2013, 11:23:44 AM7/18/13
to jenkin...@googlegroups.com
On 07/18/2013 06:24 AM, David Mata Gorriz wrote:
> In the last weeks, we had to add guava as a dependency to avoid
>
> java.lang.NoClassDefFoundError: com/google/common/cache/CacheBuilder
>
> Do you know why is that?

Perhaps you are using Maven 2? Use Maven 3.0.5 to get correct dependency resolution.

David Mata Gorriz

unread,
Jul 18, 2013, 2:32:53 PM7/18/13
to jenkin...@googlegroups.com
Thanks, but it didn't work.

Caused by: java.lang.ClassNotFoundException: com.google.common.cache.CacheBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

Perhaps artifactory plugin is involved. I have some issues with it.
And new Maven 3.1.0 neither.

<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /slavejenkins/workspace/jenkinsplugin/pom.xml -U clean cobertura:cobertura jar:jar install:install javadoc:javadoc javadoc:jar source:jar
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:174)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/cli/MavenLoggerManager
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:73)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
... 19 more
------------------------------------------------

David Mata Górriz
Arquitectura Core Bancario
Carretera de Sierra Alhamilla S/N
Edificio Celulosa 2ª Planta Almería
950180360. Extensión: 12628
David...@tecnologia.cajamar.es


-----Mensaje original-----
De: jenkin...@googlegroups.com [mailto:jenkin...@googlegroups.com] En nombre de Jesse Glick
Enviado el: jueves, 18 de julio de 2013 17:24
Para: jenkin...@googlegroups.com
Asunto: Re: NoClassDefFoundError: com/google/common/cache/CacheBuilder
--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jesse Glick

unread,
Jul 18, 2013, 3:17:12 PM7/18/13
to jenkin...@googlegroups.com
On 07/18/2013 02:32 PM, David Mata Gorriz wrote:
> <===[JENKINS REMOTING CAPACITY]===>channel started

Wait, you mean you cannot run your plugin’s tests from the command line? Or from a build of a Jenkins Maven-type job? If the latter, try switching to a freestyle job with
a Maven build step.

Kohsuke Kawaguchi

unread,
Jul 22, 2013, 9:13:04 PM7/22/13
to jenkin...@googlegroups.com, David Mata Gorriz

My guess is that your plugin depends on Guava directly or indirectly,
overwriting the version that Jenkins core uses.

Check "mvn dependency:tree" output and the path that leads to the guava.

On 07/18/2013 03:24 AM, David Mata Gorriz wrote:
> Hi, everyone.
>
> We have a plugin in our company to do some specific tasks. In the last
> weeks, we had to add guava as a dependency to avoid
>
> java.lang.NoClassDefFoundError: com/google/common/cache/CacheBuilder
>
> at hudson.model.Queue.<init>(Queue.java:188)
>
> at jenkins.model.Jenkins.<init>(Jenkins.java:764)
>
> at hudson.model.Hudson.<init>(Hudson.java:81)
>
> at
> org.jvnet.hudson.test.HudsonTestCase.newHudson(HudsonTestCase.java:469)
>
> at
> org.jvnet.hudson.test.HudsonTestCase.setUp(HudsonTestCase.java:312)
>
> at junit.framework.TestCase.runBare(TestCase.java:139)
>
> at
> org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:290)
>
> at junit.framework.TestResult$1.protect(TestResult.java:122)
>
> Do you know why is that? I think we shouldn�t be required to do it.
>
> Maybe I made a mistake, or some of the plugins I use (artifactory,
> sonar, svn).
>
> Thanks
>
>
> ------------------------------------------------------------------------
> AVISO DE CONFIDENCIALIDAD
> Este correo electr�nico y cualquier fichero con el transmitido son
> confidenciales, contienen informaci�n privilegiada y son de conocimiento
> y uso exclusivo de la persona o entidad a quienes han sido dirigidos. Su
> contenido no puede ser modificado. En caso de recibir este mensaje por
> error, le rogamos que informe de inmediato al remitente y proceda a
> destruir dicho mensaje y cualquier copia que hubiese realizado. Como el
> correo electr�nico puede verse afectado por fallos t�cnicos u
> operacionales, no se garantiza su recepci�n de forma adecuada y puede
> estar sujeta a retrasos. Cualquier
> comunicaci�n que est� supeditada a una fecha u hora pactadas
> previamente, tambi�n deber� ser enviada por correo convencional o fax.
> El correo electr�nico no garantiza la confidencialidad del contenido de
> los mensajes. Si el destinatario de este mensaje tiene cualquier
> objeci�n a la utilizaci�n de este medio, deber� ponerse en contacto de
> inmediato con el remitente. Est� estrictamente prohibido el uso, copia o
> distribuci�n por cualquier medio no autorizado de este mensaje y de
> cualquier fichero en el contenido.
> CONFIDENTIALITY WARNING
> This e-mail and any files transmitted with it are confidential and
> privileged, and are intented solely for the use of the individual or
> entity to whom they are addressed. Their contents may not be altered. If
> you are not the intended recipient of this communication please notify
> the sender and delete and destroy all copies immediately. As e-mail can
> be subject to operational or technical difficulties, the quality of
> reception may be affected and it is subject to time delays. Therefore,
> communications that are subject to deadlines should also be sent by post
> or fax. Please note that one cannot guarantee the confidentiality of
> e-mail messages. If the recipient of this message objects to the use of
> Internet e-mail, please notify the sender immediately. Any unauthorised
> direct or indirect use, dissemination, distribution or copying of this
> message is prohibited.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jenkinsci-de...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Jenkins Enterprise, our professional version of Jenkins

Jesse Glick

unread,
Jul 23, 2013, 2:08:18 PM7/23/13
to jenkin...@googlegroups.com
On 07/22/2013 09:13 PM, Kohsuke Kawaguchi wrote:
> My guess is that your plugin depends on Guava directly or indirectly, overwriting the version that Jenkins core uses.

And Stephen Connolly found that attempting to do this does not work. (Specifically getting a NCDFE on CacheBuilder, in fact.) Use the version of Guava bundled with Jenkins.

Stephen Connolly

unread,
Jul 23, 2013, 3:55:38 PM7/23/13
to jenkin...@googlegroups.com
Which lead to another of my curse rants for Jenkins exposing in its API a dependency that is more fast and loose with Backwards Compatibility than Jenkins...

Here is my list of dependencies that should *NOT* be exposed by Jenkins:

- BouncyCastle (top if the list)
- ASM (before they got their act together... Even still not sure)
- Guava

I am sure there are others, but I have been bitten more than once by all of these and I am now of the opinion that if we change the bundled version of any of those in Jenkins we need to bump the major version as it is not following semver otherwise

(Just my personal opinion... Haven't had the chance to beat the sense into KK about it yet... Copenhagen in Sep may be such a chance!)
 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
Sent from my phone

Jesse Glick

unread,
Jul 23, 2013, 4:57:41 PM7/23/13
to jenkin...@googlegroups.com
On 07/23/2013 03:55 PM, Stephen Connolly wrote:
> Here is my list of dependencies that should *NOT* be exposed by Jenkins:
>
> - BouncyCastle (top if the list)
> - ASM (before they got their act together... Even still not sure)
> - Guava

Would I guess suffice to shade these? But then we have to deal with plugins that are already using them.

Stephen Connolly

unread,
Jul 23, 2013, 7:02:12 PM7/23/13
to jenkin...@googlegroups.com
It would suffice to exclude them from the plugin's classloader. Shading only moves the problem... unless we shade like I shade bouncycastle for cloudbees-license (i.e. into a package name that includes the version of the dependency)

Fundamentally when adding a dependency to core we need to either be sure that the dependency has the same view of backwards compatibility as we have or bump the major version every time we up that dependency.


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

Jesse Glick

unread,
Jul 23, 2013, 7:24:56 PM7/23/13
to jenkin...@googlegroups.com
On 07/23/2013 07:02 PM, Stephen Connolly wrote:
> unless we shade like I shade bouncycastle for cloudbees-license (i.e. into a package name that includes the version of the dependency)

That is what I meant.

Stephen Connolly

unread,
Jul 24, 2013, 2:45:04 AM7/24/13
to jenkin...@googlegroups.com
Well if core ups its dependency, we'd need to have core bundle both, as that would be breaking backward compatibility.... Which again pushes towards a major version bump
 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


David Mata Gorriz

unread,
Jul 24, 2013, 5:46:59 AM7/24/13
to jenkin...@googlegroups.com
You are right, as usual. Artifactory 2.1.6 depends on guava r08 and jenkins depends on 1.0.1.

------------------------------------------------

David Mata Górriz
Arquitectura Core Bancario
Carretera de Sierra Alhamilla S/N
Edificio Celulosa 2ª Planta Almería
950180360. Extensión: 12628
David...@tecnologia.cajamar.es

-----Mensaje original-----
De: jenkin...@googlegroups.com [mailto:jenkin...@googlegroups.com] En nombre de Kohsuke Kawaguchi
Enviado el: martes, 23 de julio de 2013 3:13
Para: jenkin...@googlegroups.com
CC: David Mata Gorriz
Asunto: Re: NoClassDefFoundError: com/google/common/cache/CacheBuilder


My guess is that your plugin depends on Guava directly or indirectly,
overwriting the version that Jenkins core uses.

Check "mvn dependency:tree" output and the path that leads to the guava.

On 07/18/2013 03:24 AM, David Mata Gorriz wrote:
> Hi, everyone.
>
> We have a plugin in our company to do some specific tasks. In the last
> weeks, we had to add guava as a dependency to avoid
>
> java.lang.NoClassDefFoundError: com/google/common/cache/CacheBuilder
>
> at hudson.model.Queue.<init>(Queue.java:188)
>
> at jenkins.model.Jenkins.<init>(Jenkins.java:764)
>
> at hudson.model.Hudson.<init>(Hudson.java:81)
>
> at
> org.jvnet.hudson.test.HudsonTestCase.newHudson(HudsonTestCase.java:469)
>
> at
> org.jvnet.hudson.test.HudsonTestCase.setUp(HudsonTestCase.java:312)
>
> at junit.framework.TestCase.runBare(TestCase.java:139)
>
> at
> org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:290)
>
> at junit.framework.TestResult$1.protect(TestResult.java:122)
>
> Do you know why is that? I think we shouldn't be required to do it.
>
> Maybe I made a mistake, or some of the plugins I use (artifactory,
> sonar, svn).
>
> Thanks
>
>
> ------------------------------------------------------------------------
> AVISO DE CONFIDENCIALIDAD
> Este correo electrónico y cualquier fichero con el transmitido son
> confidenciales, contienen información privilegiada y son de conocimiento
> y uso exclusivo de la persona o entidad a quienes han sido dirigidos. Su
> contenido no puede ser modificado. En caso de recibir este mensaje por
> error, le rogamos que informe de inmediato al remitente y proceda a
> destruir dicho mensaje y cualquier copia que hubiese realizado. Como el
> correo electrónico puede verse afectado por fallos técnicos u
> operacionales, no se garantiza su recepción de forma adecuada y puede
> estar sujeta a retrasos. Cualquier
> comunicación que esté supeditada a una fecha u hora pactadas
> previamente, también deberá ser enviada por correo convencional o fax.
> El correo electrónico no garantiza la confidencialidad del contenido de
> los mensajes. Si el destinatario de este mensaje tiene cualquier
> objeción a la utilización de este medio, deberá ponerse en contacto de
> inmediato con el remitente. Está estrictamente prohibido el uso, copia o
> distribución por cualquier medio no autorizado de este mensaje y de
AVISO DE CONFIDENCIALIDAD
Este correo electrónico y cualquier fichero con el transmitido son confidenciales, contienen información privilegiada y son de conocimiento y uso exclusivo de la persona o entidad a quienes han sido dirigidos. Su contenido no puede ser modificado. En caso de recibir este mensaje por error, le rogamos que informe de inmediato al remitente y proceda a destruir dicho mensaje y cualquier copia que hubiese realizado. Como el correo electrónico puede verse afectado por fallos técnicos u operacionales, no se garantiza su recepción de forma adecuada y puede estar sujeta a retrasos. Cualquier
comunicación que esté supeditada a una fecha u hora pactadas previamente, también deberá ser enviada por correo convencional o fax. El correo electrónico no garantiza la confidencialidad del contenido de los mensajes. Si el destinatario de este mensaje tiene cualquier objeción a la utilización de este medio, deberá ponerse en contacto de inmediato con el remitente. Está estrictamente prohibido el uso, copia o distribución por cualquier medio no autorizado de este mensaje y de cualquier fichero en el contenido.

Adrien Lecharpentier

unread,
Nov 28, 2013, 10:33:52 AM11/28/13
to jenkin...@googlegroups.com, david...@tecnologia.cajamar.es
(old topic but same issue, sorry)
Hi,

I have the same error with a new plugin, for which I wanted to use guava 15.0. I understand you cannot embedded guava in core but maybe for the next jenkins' plugins parent pom we should use a <dependencyManagement/> for both com.google.guava:guava and com.google.code.findbugs:jsr305.

If we do so, any IDE, developers could see that they are overriding the version for those dependencies.

Details: using maven 3.1.1 with org.jenkins-ci.plugins:plugin:1.509.4. My problem was that I couldn't test my plugin due to Guava API modification:

Results :
Tests in error:
  org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyTestSuite(org.jvnet.hudson.test.junit.FailedTest): tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class com.google.inject.internal.Annotations$AnnotationChecker
  testCliSanity(org.jvnet.hudson.test.PluginAutomaticTestBuilder$CliSanityTest): Could not initialize class org.eclipse.sisu.wire.ParameterKeys

And using version 11.0.1 of guava and 1.3.9 of jsr305 fixed it.
 
Thanks.

Nigel Magnay

unread,
Mar 8, 2014, 7:04:31 AM3/8/14
to jenkin...@googlegroups.com
Aaand... I've just been bitten by this too.

Dependency uses guava 15 (and, indeed, 17 in later versions), fails bigtime when running in Jenkins, even though the library gets included in WEB-INF/lib.

I understand I could fix this with shading... but shading always sounds to me like a craptastic hack for a problem that ought not to exist. Guava 11 is getting rather old, more and more plugins are gonna suffer this.

What's the core issue? Couldn't Jenkins do the shading, if required, at plugin load time?
Reply all
Reply to author
Forward
0 new messages