3
votes

I am trying to integrate Sonar with Jenkins. Everything is setup and running successfully. When I build the project in Jenkins, it says ANALYSIS SUCCESSFUL but the build fails with the following error.

[INFO] [15:59:54.852] ANALYSIS SUCCESSFUL, you can browse http://mysonarurl.com/sonar/dashboard/index/myproject

[ERROR] Unable to evict preview database: /batch_bootstrap/evict?project=68
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: Unable to evict preview database: /batch_bootstrap/evict?project=68
Read timed out
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:103)
    at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to evict preview database: /batch_bootstrap/evict?project=68
    at org.sonar.maven.ExceptionHandling.handle(ExceptionHandling.java:37)
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:175)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:98)
    ... 21 more
Caused by: org.sonar.api.utils.SonarException: Unable to evict preview database: /batch_bootstrap/evict?project=68
    at org.sonar.batch.phases.UpdateStatusJob.evictPreviewDB(UpdateStatusJob.java:82)
    at org.sonar.batch.phases.UpdateStatusJob.execute(UpdateStatusJob.java:68)
    at org.sonar.batch.phases.PhaseExecutor.updateStatusJob(PhaseExecutor.java:155)
    at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:131)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:150)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:211)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:206)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:199)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:58)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:144)
    at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:132)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
    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)
    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:90)
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:173)
    ... 23 more
Caused by: org.sonar.api.utils.SonarException: Unable to request: /batch_bootstrap/evict?project=68
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:92)
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:82)
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:78)
    at org.sonar.batch.phases.UpdateStatusJob.evictPreviewDB(UpdateStatusJob.java:80)
    ... 58 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1514)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1508)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1162)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
    at org.sonar.api.utils.HttpDownloader$BaseHttpDownloader$HttpInputSupplier.getInput(HttpDownloader.java:274)
    at org.sonar.api.utils.HttpDownloader$BaseHttpDownloader$HttpInputSupplier.getInput(HttpDownloader.java:235)
    at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:88)
    ... 61 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:709)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1218)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2340)
    at java.net.URLConnection.getContentEncoding(URLConnection.java:496)
    at org.sonar.api.utils.HttpDownloader$BaseHttpDownloader$HttpInputSupplier.getInput(HttpDownloader.java:272)

Before I got this error, it was showing 'java heap space' error but it got resolved after adding -Xmx1024m to the MAVEN_OPTS.

Any help about this error would be greatly appreciated. Thanks in advance.

1
This might be of help: stackoverflow.com/questions/12583065/… Regards - Qualilogy
Do you get this everytime? What do you have in the logs of SonarQube server? (in "<install_dir>/logs/sonar.log") - Fabrice - SonarSource Team
When I deleted the project from Jenkins and configured it again, it was successful for the first time. After that it fails everytime I run the build. I got this log from Jenkins but nothing shows up in "sonar.log" even if i run the build again. FYI, Sonarqube 4.1 (Native package installed) and Jenkins are running in Mac OS X 10.8.5. - Slowcoder
Additional point: This happens for only one project which is little bigger than other (maven) projects I have. sonar runs for the other small projects just fine. - Slowcoder

1 Answers

1
votes

We are running Jenkins, Sonar and a PostgreSQL Server on the same (Ubuntu) machine and had the same issue after upgrading from Sonar 3.3 to SonarQube 4.1 and running an analysis on a big project with over 890k LOCs.

First we got the OutOfMemmoryException you mentioned, we resolved it by setting -Xmx to 2048m. The first run after resolving the memory issue was successful, but all following runs failed with

[ERROR] Unable to evict preview database: /batch_bootstrap/evict?... .

After some time, we found ONE out of 6 build, that failed with the following exception:

java.io.FileNotFoundException: /some/path/someFile.java (Too many open files).

We have not seen this exception in any of the sonar or jenkins logs before. So we changed the open file limit from 1024 (default on ubuntu) to 4096 and restartet Jenkins, Sonar and the PostgreSQL Server. Since then, all builds pass.