SonarQube scanner ran though jenkins pipeline failed to analyze java code-Too many open files

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Community Edition V-9.9 (build 65466)
    SonarScanner 4.8.0.2856
    Findbugs:4.2.9
    java:1.8.0_73
  • how is SonarQube deployed: docker
  • what are you trying to achieve
    Using jenkins to start the scanner of sonar,then generate report in sonarqube
  • what have you tried so far to achieve this
    restart sonar service,restart jenkins service
    change parameters of jenkins server like follows:
    sysctl -w vm.max_map_count=524288
    sysctl -w fs.file-max=131072
    ulimit -n 131072
    ulimit -u 8192
    *error Logs:
+ /usr/local/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=platform-auth -Dsonar.projectName=platform-auth -Dsonar.sourceEncoding=UTF-8 -Dsonar.language=java -Dsonar.java.jdkHome=/usr/java8/jdk1.8.0_73/ -Dsonar.java.source=1.8 -Dsonar.sources=./platform-auth-api/src,./platform-auth-service/src -Dsonar.java.binaries=./platform-auth-api/target,./platform-auth-service/target -Dsonar.java.libraries=/data/maven/repository/platform -Dsonar.login=admin -Dsonar.password=****
INFO: Scanner configuration file: /usr/local/sonar-scanner-4.8.0.2856-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)
INFO: Linux 3.10.0-1160.71.1.el7.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Analyzing on SonarQube server 9.9.0.65466
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=353ms
INFO: Server id: 147B411E-AYZx2WZsk_owHOrDbGMH
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=267ms
INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
INFO: Load/download plugins (done) | time=843ms
INFO: Process project properties
INFO: Process project properties (done) | time=10ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: platform-auth
INFO: Base dir: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth
INFO: Working dir: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/.scannerwork
INFO: Load project settings for component key: 'platform-auth'
INFO: Load project settings for component key: 'platform-auth' (done) | time=216ms
INFO: Auto-configuring with CI 'Jenkins'
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=288ms
INFO: Load active rules
INFO: Load active rules (done) | time=13410ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=241ms
WARN: Property 'sonar.password' is deprecated. It will not be supported in the future. Please instead use the 'sonar.login' parameter with a token.
INFO: Load project repositories
INFO: Load project repositories (done) | time=232ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 185 files indexed
INFO: Quality profile for java: sonar+fsb
INFO: Quality profile for json: Sonar way
INFO: Quality profile for yaml: Sonar way
INFO: ------------- Run sensors on module platform-auth
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=216ms
INFO: Sensor JavaSensor [java]
INFO: Configured Java source version (sonar.java.source): 8
INFO: JavaClasspath initialization
WARN: Invalid value for 'sonar.java.jdkHome' property, defaulting to runtime JDK.
Configured location does not exists: '/usr/java8/jdk1.8.0_73'
INFO: JavaClasspath initialization (done) | time=15004ms
INFO: JavaTestClasspath initialization
WARN: Invalid value for 'sonar.java.jdkHome' property, defaulting to runtime JDK.
Configured location does not exists: '/usr/java8/jdk1.8.0_73'
INFO: JavaTestClasspath initialization (done) | time=0ms
INFO: Server-side caching is enabled. The Java analyzer will not try to leverage data from a previous analysis.
INFO: Using ECJ batch to parse 135 Main java source files with batch size 207 KB.
INFO: Starting batch processing.
INFO: 0% analyzed
INFO: 0% analyzed
INFO: 0% analyzed
INFO: 0% analyzed
INFO: 0% analyzed
INFO: No "Test" source files to scan.
INFO: No "Generated" source files to scan.
INFO: Sensor JavaSensor [java] (done) | time=67957ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
INFO: Sensor IaC CloudFormation Sensor [iac]
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml: Too many open files
INFO: 0 source files to be analyzed
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml: Too many open files
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=17ms
INFO: Sensor IaC Kubernetes Sensor [iac]
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml: Too many open files
INFO: 0 source files to be analyzed
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/postman/platform_auth_api_.json: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml: Too many open files
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Kubernetes Sensor [iac] (done) | time=5ms
INFO: Sensor JavaScript inside YAML analysis [javascript]
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application-dev.yml: Too many open files
ERROR: Unable to read file: file:///var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml.
ERROR: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-service/src/main/resources/application.yml: Too many open files
INFO: No input files found for analysis
INFO: Hit the cache for 0 out of 0
INFO: Miss the cache for 0 out of 0
INFO: Sensor JavaScript inside YAML analysis [javascript] (done) | time=4ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=1ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=0ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=14ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor FindBugs Sensor [findbugs]
INFO: Findbugs plugin version: 4.2.9
INFO: Loading findbugs plugin: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/.scannerwork/findbugs/findsecbugs-plugin.jar
INFO: Findbugs output report: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/.scannerwork/findbugs-result.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:36.210s
INFO: Final Memory: 23M/90M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Can not execute Findbugs
	at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:191)
	at org.sonar.plugins.findbugs.FindbugsSensor.execute(FindbugsSensor.java:132)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.io.IOException: IOException while scanning codebases
	at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
	at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:182)
	... 31 more
Caused by: java.lang.RuntimeException: java.io.IOException: IOException while scanning codebases
	at com.google.common.base.Throwables.propagate(Throwables.java:240)
	at org.sonar.plugins.findbugs.FindbugsExecutor$FindbugsTask.call(FindbugsExecutor.java:239)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: IOException while scanning codebases
	at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:311)
	at org.sonar.plugins.findbugs.FindbugsExecutor$FindbugsTask.call(FindbugsExecutor.java:236)
	... 4 more
Caused by: edu.umd.cs.findbugs.classfile.ResourceNotFoundException: Resource not found: /var/lib/jenkins/workspace/package-snapshot-backend-platform-auth/platform-auth-api/target/classes/com/inovance/platform/auth/enums/PasswordResetTypeEnum.class
	at edu.umd.cs.findbugs.classfile.impl.SingleFileCodeBase.getClassDescriptor(SingleFileCodeBase.java:279)
	at edu.umd.cs.findbugs.classfile.impl.SingleFileCodeBaseEntry.getClassDescriptor(SingleFileCodeBaseEntry.java:82)
	at edu.umd.cs.findbugs.classfile.impl.ClassPathBuilder.build(ClassPathBuilder.java:259)
	at edu.umd.cs.findbugs.FindBugs2.buildClassPath(FindBugs2.java:708)
	at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:245)
	... 5 more

I have tried to analyze other project without java language,then it successed without error.
Moreover,the .scannerwork dir will be removed everytime the scan is over,including success and failed.
Then I tried to run the command in the console of jenkins server,then it successed,but ran it though jenkins job pipeline,it failed.
I don’t know what difference between console of jenkins server and jenkins pipeline

Hi,

This is a problem with the FindBugs plugin. You should report it to the FindBugs maintainers.

 
HTH,
Ann

OK,thank you for your answers.It has been solved after upgrade both sonar and findbugs

1 Like