0
votes

I'm trying to configure the SonarQube 4.5.4 on my server. For that SonarQube version, it needs jdk 1.7, in case of building my Android system firmware, only jdk 1.6 can be set as the default jdk.

Now jdk 1.7 is still on my Computer, not the defalut one. So in order to make SonarQube run, the jdk 1.7's absolute path is specified in /conf/wrapper.conf under the following line:

wrapper.java.command=/usr/lib/jvm/java-7-oracle/jre/bin/java

After this, the jdk 1.7 can be seen from Sonar's setting: enter image description here

Ok, the sonar-runner is ready to analysis a demo code. Unfortunately, an error was throw:

emporia@emporia-ubuntu:~/Lawrence/sonar-examples-master/projects/languages/java/sonar-runner/java-sonar-runner-simple$ sonar-runner -X SonarQube Runner 2.4 Java 1.6.0_45 Sun Microsystems Inc. (64-bit) Linux 2.6.32-62-generic amd64 INFO: Error stacktraces are turned on. INFO: Runner configuration file: /opt/sonar-runner-2.4/conf/sonar-runner.properties INFO: Project configuration file: /home/emporia/Lawrence/sonar-examples-master/projects/languages/java/sonar-runner/java-sonar-runner-simple/sonar-project.properties INFO: Default locale: "en_US", source code encoding: "UTF-8" INFO: Work directory: /home/emporia/Lawrence/sonar-examples-master/projects/languages/java/sonar-runner/java-sonar-runner-simple/./.sonar INFO: SonarQube Server 4.5.4 16:42:00.393 INFO - Load global referentials... 16:42:00.442 DEBUG - Download: http://localhost:9000/batch/global (no proxy) 16:42:00.799 INFO - Load global referentials done: 409 ms 16:42:00.873 INFO - User cache: /home/emporia/.sonar/cache 16:42:01.524 INFO - Install plugins 16:42:01.524 DEBUG - Download index of plugins 16:42:01.524 DEBUG - Download: http://localhost:9000/deploy/plugins/index.txt (no proxy) INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ Total time: 3.208s Final Memory: 2M/240M INFO: ------------------------------------------------------------------------ ERROR: Error during Sonar runner execution org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91) at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) at java.security.AccessController.doPrivileged(Native Method) at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) at org.sonar.runner.api.Runner.execute(Runner.java:100) at org.sonar.runner.Main.executeTask(Main.java:70) at org.sonar.runner.Main.execute(Main.java:59) at org.sonar.runner.Main.main(Main.java:53) Caused by: org.sonar.api.utils.SonarException: The plugin java is not supported with Java 1.6.0_45 at org.sonar.core.plugins.PluginClassloaders.instantiatePlugin(PluginClassloaders.java:230) at org.sonar.core.plugins.PluginClassloaders.init(PluginClassloaders.java:97) at org.sonar.batch.bootstrap.BatchPluginRepository.doStart(BatchPluginRepository.java:99) at org.sonar.batch.bootstrap.BatchPluginRepository.start(BatchPluginRepository.java:72) 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.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) at org.picocontainer.behaviors.Stored.start(Stored.java:110) at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015) at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008) at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) at org.sonar.batch.bootstrapper.Batch.start(Batch.java:81) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67) at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) 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.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) ... 9 more Caused by: java.lang.UnsupportedClassVersionError: org/sonar/plugins/java/JavaPlugin : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389) at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:242) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227) at org.sonar.core.plugins.PluginClassloaders.instantiatePlugin(PluginClassloaders.java:226) ... 34 more

Since the jdk 1.7 is already set for SonarQube 4.5.4, why does it throw this error? Should I still need to specify jdk 1.7 for Sonar-runner, but I didn't find the place to configure it.

1

1 Answers

0
votes

Specify a java for Sonar-runner in a hack way:

  1. Edit the file<sonar_runner_directory>/bin/sonar-runner
  2. Find the line JAVA_CMD="'which java'"
  3. Change the command with your target java's absolute path, like mine:JAVA_CMD=/usr/lib/jvm/java-7-oracle/jre/binjava.