java.lang.NoClassDefFoundError: com/google/common/base/Charsets

1,167 views
Skip to first unread message

ST

unread,
Dec 14, 2016, 6:07:12 AM12/14/16
to SonarQube
Hello all,

Facing error "java.lang.NoClassDefFoundError: com/google/common/base/Charsets" when starting sonarqube 5.6.2 server
It seems that error is with my plugin.
I tried adding maven dependency for guava.jar (versions 18, 20 etc.) and by adding the jar as external jar.
However it did not work

Here is my sonar.log file contents.

2016.12.14 16:28:14 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.NoClassDefFoundError: com/google/common/base/Charsets
at org.sonar.squidbridge.rules.ExternalDescriptionLoader.addHtmlDescription(ExternalDescriptionLoader.java:58) ~[na:na]
at org.sonar.squidbridge.rules.ExternalDescriptionLoader.addHtmlDescription(ExternalDescriptionLoader.java:51) ~[na:na]
at org.sonar.squidbridge.rules.ExternalDescriptionLoader.loadHtmlDescriptions(ExternalDescriptionLoader.java:44) ~[na:na]
at org.sonar.plugins.jdoctor.rules.JDoctorRulesDefinition.define(JDoctorRulesDefinition.java:38) ~[na:na]
at org.sonar.server.rule.RuleDefinitionsLoader.load(RuleDefinitionsLoader.java:54) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.rule.RegisterRules.start(RegisterRules.java:97) ~[sonar-server-5.6.2.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.15.jar:na]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.15.jar:na]
at org.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:320) ~[sonar-core-5.6.2.jar:na]
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.15.jar:na]
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.15.jar:na]
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.15.jar:na]
at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.15.jar:na]
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016) ~[picocontainer-2.15.jar:na]
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009) ~[picocontainer-2.15.jar:na]
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) ~[picocontainer-2.15.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141) ~[sonar-core-5.6.2.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:84) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:45) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:80) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:44) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:77) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:201) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.Platform.doStart(Platform.java:114) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.Platform.doStart(Platform.java:99) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:44) ~[sonar-server-5.6.2.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Charsets
at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39) ~[sonar-classloader-1.0.jar:na]
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87) ~[sonar-classloader-1.0.jar:na]
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76) ~[sonar-classloader-1.0.jar:na]
... 39 common frames omitted
2016.12.14 16:28:14 ERROR web[o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file
2016.12.14 16:28:14 ERROR web[o.a.c.c.StandardContext] Context [] startup failed due to previous errors
2016.12.14 16:28:14 INFO  web[o.a.c.h.Http11NioProtocol] Starting ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.12.14 16:28:14 INFO  web[o.s.s.a.TomcatAccessLog] Web server is started
2016.12.14 16:28:14 INFO  web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2016.12.14 16:28:14 WARN  web[o.s.p.ProcessEntryPoint] Fail to start web
java.lang.IllegalStateException: Webapp did not start
at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.app.WebServer.isUp(WebServer.java:47) [sonar-server-5.6.2.jar:na]
at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-5.6.2.jar:na]
at org.sonar.server.app.WebServer.main(WebServer.java:68) [sonar-server-5.6.2.jar:na]
2016.12.14 16:28:14 INFO  web[o.a.c.h.Http11NioProtocol] Pausing ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.12.14 16:28:15 INFO  web[o.a.c.h.Http11NioProtocol] Stopping ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.12.14 16:28:15 INFO  web[o.a.c.h.Http11NioProtocol] Destroying ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.12.14 16:28:15 INFO  web[o.s.s.a.TomcatAccessLog] Web server is stopped
2016.12.14 16:28:15 INFO  app[o.s.p.m.Monitor] Process[es] is stopping
2016.12.14 16:28:16 INFO   es[o.s.p.StopWatcher]  Stopping process
2016.12.14 16:28:16 INFO   es[o.elasticsearch.node]  [sonar-1481713079509] stopping ...
2016.12.14 16:28:16 INFO   es[o.elasticsearch.node]  [sonar-1481713079509] stopped
2016.12.14 16:28:16 INFO   es[o.elasticsearch.node]  [sonar-1481713079509] closing ...
2016.12.14 16:28:16 INFO   es[o.elasticsearch.node]  [sonar-1481713079509] closed
2016.12.14 16:28:16 INFO  app[o.s.p.m.Monitor] Process[es] is stopped

Any help is appreciated.


Julien Lancelot

unread,
Dec 14, 2016, 7:35:07 AM12/14/16
to ST, SonarQube
Hi,

From the error, I can see that your issue is coming from a plugin "jdoctor". You should remove it and everything should be fine.
I don't see it anywhere in the plugins library, so I can't tell you if there's a compatible version of this plugin with SonarQube 5.6.

Regards,

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/94206735-8bbe-4a17-8044-88468a305310%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Julien LANCELOT | SonarSource

Simon Brandhof

unread,
Dec 14, 2016, 7:39:48 AM12/14/16
to Julien Lancelot, ST, SonarQube
If you are the maintainer of this plugin, then note that plugin classloaders are isolated if they are built with sonar-plugin-api 5.2 or greater. Guava should be packaged within the plugin. See http://docs.sonarqube.org/display/DEV/API+Basics#APIBasics-Third-partyLibraries for more details.

Regards


For more options, visit https://groups.google.com/d/optout.
--
Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

ST

unread,
Dec 14, 2016, 8:19:43 AM12/14/16
to SonarQube, julien....@sonarsource.com, thakare...@gmail.com
Hi,

Yes, actually I am migrating my plugin from sonar-plugin-api 4.5 to sonar-plugin-api 5.6
Here I did not get you "Guava should be packaged within the plugin"  ?
and here I can see the class 'com/google/common/base/Charsets' is present in guava-10.0.1.jar under maven dependencies

Regards,
Swati

ST

unread,
Dec 14, 2016, 8:24:08 AM12/14/16
to SonarQube, thakare...@gmail.com
Hello,

Yes, it is my custom plugin which I am migrating from sonar-plugin-api version 4.5 to 5.6
and If I remove my plugin from 'extensions -> plugins' it will work.
However I need to execute my plugin.

Regards,
Swati

Simon Brandhof

unread,
Dec 14, 2016, 8:26:57 AM12/14/16
to ST, SonarQube
If it's a Maven project, the Guava dependency should be defined with scope "compile" (default) but not "provided". You can check that it's packaged within plugin by verifying the build logs. All the packaged dependencies are logged are the end.


For more options, visit https://groups.google.com/d/optout.
--

ST

unread,
Dec 15, 2016, 1:24:11 AM12/15/16
to SonarQube, thakare...@gmail.com
Hello,

Yes, its a maven project. when I add maven dependency for Guava-10.0.1.jar (added in default scope compile ), it gives another error .
"java.lang.IllegalStateException: Unable to read plugin manifest from jar"

Here are the contents of sonar.log file

016.12.15 11:49:47 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: Unable to read plugin manifest from jar : C:\Users\A602312\Documents\SOFTWARES\sonarqube-5.6.2\extensions\plugins\jdoctor-sonar-plugin-1.0.1-SNAPSHOT.jar
at org.sonar.updatecenter.common.PluginManifest.<init>(PluginManifest.java:113) ~[sonar-update-center-common-1.13.jar:na]
at org.sonar.core.platform.PluginInfo.create(PluginInfo.java:366) ~[sonar-core-5.6.2.jar:na]
at org.sonar.server.plugins.ServerPluginRepository.loadPreInstalledPlugins(ServerPluginRepository.java:136) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.plugins.ServerPluginRepository.start(ServerPluginRepository.java:112) ~[sonar-server-5.6.2.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.15.jar:na]
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.15.jar:na]
at org.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:320) ~[sonar-core-5.6.2.jar:na]
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.15.jar:na]
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.15.jar:na]
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.15.jar:na]
at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.15.jar:na]
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016) ~[picocontainer-2.15.jar:na]
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009) ~[picocontainer-2.15.jar:na]
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) ~[picocontainer-2.15.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141) ~[sonar-core-5.6.2.jar:na]
at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:84) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.Platform.start(Platform.java:216) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.Platform.startLevel2Container(Platform.java:182) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.Platform.init(Platform.java:91) ~[sonar-server-5.6.2.jar:na]
at org.sonar.server.platform.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43) ~[sonar-server-5.6.2.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]
Caused by: java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:406) ~[na:1.8.0_102]
at java.util.jar.Manifest.read(Manifest.java:199) ~[na:1.8.0_102]
at java.util.jar.Manifest.<init>(Manifest.java:69) ~[na:1.8.0_102]
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:194) ~[na:1.8.0_102]
at java.util.jar.JarFile.getManifest(JarFile.java:180) ~[na:1.8.0_102]
at org.sonar.updatecenter.common.PluginManifest.<init>(PluginManifest.java:109) ~[sonar-update-center-common-1.13.jar:na]
... 32 common frames omitted

Simon Brandhof

unread,
Dec 15, 2016, 1:47:56 AM12/15/16
to ST, SonarQube
The version of sonar-packaging-maven-plugin is probably very old. You should upgrade to version 1.17 : http://search.maven.org/#artifactdetails%7Corg.sonarsource.sonar-packaging-maven-plugin%7Csonar-packaging-maven-plugin%7C1.17%7Cmaven-plugin
Please note that groupId changed.


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

ST

unread,
Dec 15, 2016, 2:34:10 AM12/15/16
to SonarQube, thakare...@gmail.com
Hello Simon,

I upgraded it from 1.15 to 1.17 but it does not works.
One more thing is when I build the plugin, the guava-10.0.1.jar and guava-18.0.jar gets downloaded in maven repository for both my plugin-project and plugin-parent project.
and in eclipse I can open 'Charsets.java' and 'Charsets.class' files.
Anyways many thanks for your help.

Simon Brandhof

unread,
Dec 15, 2016, 2:47:34 AM12/15/16
to ST, SonarQube
Can you please share your build logs ?
Thanks



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

ST

unread,
Dec 15, 2016, 3:24:08 AM12/15/16
to SonarQube, thakare...@gmail.com
Hello Simon,

I have this warning in my build logs

[WARNING] com.google.guava:guava:jar:10.0.1:compile is provided by SonarQube plugin API and will not be packaged in your plugin

Simon Brandhof

unread,
Dec 15, 2016, 3:26:27 AM12/15/16
to ST, SonarQube
What is the version of sonar-plugin-api dependency ? To make things simpler, it would be great that you share your pom and logs.


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

ST

unread,
Dec 15, 2016, 3:49:31 AM12/15/16
to SonarQube, thakare...@gmail.com
Hello Simon,

Can you please find attachments for pom.xml and build logs.

Version of <sonar-plugin-api> dependency is 5.6 but in build log I can see below line
 org.codehaus.sonar:sonar-plugin-api:jar:5.1:compile is provided by SonarQube plugin API and will not be packaged in your plugin
pom.xml
build_logs.txt

Simon Brandhof

unread,
Dec 15, 2016, 4:05:00 AM12/15/16
to ST, SonarQube
The problem is that groupId of sonar-plugin-api changed when the Codehaus forge shut down. A consequence is that conflicts of version are not resolved by Maven. The library sslr-squid-bridge brings a transitive dependency on a old sonar-plugin-api 4.5.1 :

# mvn dependency:tree
[INFO] +- org.codehaus.sonar.sslr-squid-bridge:sslr-squid-bridge:jar:2.5.3:compile
[INFO] |  +- org.codehaus.sonar.sslr:sslr-core:jar:1.20:compile
[INFO] |  +- org.codehaus.sonar.sslr:sslr-xpath:jar:1.20:compile
[INFO] |  |  \- jaxen:jaxen:jar:1.1.4:compile
[INFO] |  \- org.codehaus.sonar:sonar-plugin-api:jar:4.5.1:compile

This dependency should be excluded from your build :
<dependency>
<groupId>org.codehaus.sonar.sslr-squid-bridge</groupId>
<artifactId>sslr-squid-bridge</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
</exclusion>
</exclusions>
</dependency>

I hope it will fix your issue.
Regards


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

ST

unread,
Dec 15, 2016, 4:51:49 AM12/15/16
to SonarQube, thakare...@gmail.com
Thanks a lot Simon.
the error is resolved :)

Regards,
Swati
Reply all
Reply to author
Forward
0 new messages