SonarScanner fails due to sonar.java.binaries for PHP project?

SonarQube Version: 8.2.0.32929
SonarScanner Version: sonar-scanner-4.2.0.1873
SonarPHP Version: 3.3.0.5166

I’m running the SonarScanner against a PHP (Drupal 7) project–which does not have any *.java files within it. For some reason, the scan keeps failing with the following message:

org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property

This is rather odd to me, since I’m not trying to scan a Java project. I’ve tried passing -Dsonar.language=php among other various things, but cannot seem to get it to analyze the project properly. Any help would be greatly appreciated!

Debug dump:

00:10:53.276 INFO: Scanner configuration file: /Users/yeapiekiyay/Downloads/sonar-scanner-4.2.0.1873-macosx/conf/sonar-scanner.properties
00:10:53.278 INFO: Project root configuration file: NONE
00:10:53.295 INFO: SonarQube Scanner 4.2.0.1873
00:10:53.295 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
00:10:53.295 INFO: Mac OS X 10.15.3 x86_64
00:10:53.373 DEBUG: keyStore is :
00:10:53.374 DEBUG: keyStore type is : pkcs12
00:10:53.374 DEBUG: keyStore provider is :
00:10:53.374 DEBUG: init keystore
00:10:53.374 DEBUG: init keymanager of type SunX509
00:10:53.455 DEBUG: Create: /Users/yeapiekiyay/.sonar/cache
00:10:53.455 INFO: User cache: /Users/yeapiekiyay/.sonar/cache
00:10:53.455 DEBUG: Create: /Users/yeapiekiyay/.sonar/cache/_tmp
00:10:53.457 DEBUG: Extract sonar-scanner-api-batch in temp...
00:10:53.459 DEBUG: Get bootstrap index...
00:10:53.459 DEBUG: Download: http://my-sonarqube-server-ip:9000/batch/index
00:10:53.497 DEBUG: Get bootstrap completed
00:10:53.499 DEBUG: Create isolated classloader...
00:10:53.505 DEBUG: Start temp cleaning...
00:10:53.510 DEBUG: Temp cleaning done
00:10:53.510 DEBUG: Execution getVersion
00:10:53.517 INFO: SonarQube server 8.2.0
00:10:53.517 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
00:10:53.518 DEBUG: Work directory: /Users/yeapiekiyay/src/devilbox/data/www/my-php-application/htdocs/.scannerwork
00:10:53.518 DEBUG: Execution execute
00:10:53.680 DEBUG: Community 8.2.0.32929
00:10:53.745 INFO: Load global settings
00:10:53.778 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/settings/values.protobuf | time=32ms
00:10:53.799 INFO: Load global settings (done) | time=54ms
00:10:53.802 INFO: Server id: B5316926-AXCZX0X5TfWkLeNLqicT
00:10:53.804 INFO: User cache: /Users/yeapiekiyay/.sonar/cache
00:10:53.806 INFO: Load/download plugins
00:10:53.806 INFO: Load plugins index
00:10:53.816 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/plugins/installed | time=10ms
00:10:53.841 INFO: Load plugins index (done) | time=35ms
00:10:53.885 INFO: Load/download plugins (done) | time=79ms
00:10:53.925 DEBUG: Plugins:
00:10:53.926 DEBUG:   * SonarPython 2.5.0.5733 (python)
00:10:53.926 DEBUG:   * SonarCSS 1.2.0.1325 (cssfamily)
00:10:53.926 DEBUG:   * JaCoCo 1.0.2.475 (jacoco)
00:10:53.926 DEBUG:   * SonarGo 1.6.0.719 (go)
00:10:53.926 DEBUG:   * SonarKotlin 1.5.0.315 (kotlin)
00:10:53.926 DEBUG:   * Svn 1.9.0.1295 (scmsvn)
00:10:53.926 DEBUG:   * SonarJS 6.2.0.12043 (javascript)
00:10:53.927 DEBUG:   * SonarRuby 1.5.0.315 (ruby)
00:10:53.927 DEBUG:   * SonarScala 1.5.0.315 (sonarscala)
00:10:53.927 DEBUG:   * SonarC# 8.4.0.15306 (csharp)
00:10:53.927 DEBUG:   * SonarJava 6.1.0.20866 (java)
00:10:53.927 DEBUG:   * SonarHTML 3.2.0.2082 (web)
00:10:53.927 DEBUG:   * Git 1.9.1.1834 (scmgit)
00:10:53.927 DEBUG:   * SonarFlex 2.5.1.1831 (flex)
00:10:53.927 DEBUG:   * SonarXML 2.0.1.2020 (xml)
00:10:53.927 DEBUG:   * SonarPHP 3.3.0.5166 (php)
00:10:53.927 DEBUG:   * SonarTS 2.1.0.4359 (typescript)
00:10:53.927 DEBUG:   * SonarVB 8.4.0.15306 (vbnet)
00:10:54.234 INFO: Process project properties
00:10:54.240 INFO: Process project properties (done) | time=6ms
00:10:54.241 INFO: Execute project builders
00:10:54.241 DEBUG: Execute project builder: org.sonar.plugins.csharp.CSharpGlobalProtobufFileProcessor
00:10:54.242 DEBUG: Execute project builder: org.sonar.plugins.vbnet.VbNetGlobalProtobufFileProcessor
00:10:54.243 INFO: Execute project builders (done) | time=2ms
00:10:54.245 INFO: Project key: my-php-application
00:10:54.246 INFO: Base dir: /Users/yeapiekiyay/src/devilbox/data/www/my-php-application/htdocs
00:10:54.246 INFO: Working dir: /Users/yeapiekiyay/src/devilbox/data/www/my-php-application/htdocs/.scannerwork
00:10:54.246 DEBUG: Project global encoding: UTF-8, default locale: en_US
00:10:54.247 DEBUG: Creating module hierarchy
00:10:54.248 DEBUG:   Init module 'my-php-application'
00:10:54.248 DEBUG:     Base dir: /Users/yeapiekiyay/src/devilbox/data/www/my-php-application/htdocs
00:10:54.248 DEBUG:     Working dir: /Users/yeapiekiyay/src/devilbox/data/www/my-php-application/htdocs/.scannerwork
00:10:54.248 DEBUG:     Module global encoding: UTF-8, default locale: en_US
00:10:54.288 INFO: Load project settings for component key: 'my-php-application'
00:10:54.314 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/settings/values.protobuf?component=my-php-application | time=24ms
00:10:54.315 INFO: Load project settings for component key: 'my-php-application' (done) | time=27ms
00:10:54.373 DEBUG: Available languages:
00:10:54.373 DEBUG:   * Python => "py"
00:10:54.374 DEBUG:   * CSS => "css"
00:10:54.374 DEBUG:   * Go => "go"
00:10:54.374 DEBUG:   * Kotlin => "kotlin"
00:10:54.374 DEBUG:   * JavaScript => "js"
00:10:54.374 DEBUG:   * TypeScript => "ts"
00:10:54.374 DEBUG:   * Ruby => "ruby"
00:10:54.374 DEBUG:   * Scala => "scala"
00:10:54.374 DEBUG:   * C# => "cs"
00:10:54.374 DEBUG:   * Java => "java"
00:10:54.374 DEBUG:   * HTML => "web"
00:10:54.374 DEBUG:   * JSP => "jsp"
00:10:54.374 DEBUG:   * Flex => "flex"
00:10:54.375 DEBUG:   * XML => "xml"
00:10:54.375 DEBUG:   * PHP => "php"
00:10:54.375 DEBUG:   * VB.NET => "vbnet"
00:10:54.379 INFO: Load quality profiles
00:10:54.417 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/qualityprofiles/search.protobuf?project=my-php-application | time=37ms
00:10:54.431 INFO: Load quality profiles (done) | time=52ms
00:10:54.440 INFO: Load active rules
00:10:54.460 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYFzsTfWkLeNLqkFU&ps=500&p=1 | time=20ms
00:10:54.524 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYF5gTfWkLeNLqkGK&ps=500&p=1 | time=22ms
00:10:54.549 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYF9STfWkLeNLqkGp&ps=500&p=1 | time=20ms
00:10:54.569 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYF98TfWkLeNLqkHE&ps=500&p=1 | time=19ms
00:10:54.598 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYGB5TfWkLeNLqkH-&ps=500&p=1 | time=25ms
00:10:54.635 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYGH6TfWkLeNLqkKD&ps=500&p=1 | time=33ms
00:10:54.679 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYGiyTfWkLeNLqkRg&ps=500&p=1 | time=34ms
00:10:54.712 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYGqMTfWkLeNLqkTN&ps=500&p=1 | time=26ms
00:10:54.776 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYGwYTfWkLeNLqkXl&ps=500&p=1 | time=62ms
00:10:54.879 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYG7ZTfWkLeNLqkhh&ps=500&p=1 | time=90ms
00:10:54.915 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYHHLTfWkLeNLqkoB&ps=500&p=1 | time=23ms
00:10:54.952 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYHLsTfWkLeNLqkpP&ps=500&p=1 | time=36ms
00:10:54.972 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYHRHTfWkLeNLqkqF&ps=500&p=1 | time=18ms
00:10:55.011 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYHWhTfWkLeNLqkry&ps=500&p=1 | time=38ms
00:10:55.050 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYHjaTfWkLeNLqkwR&ps=500&p=1 | time=36ms
00:10:55.087 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXCZYHoUTfWkLeNLqkzD&ps=500&p=1 | time=34ms
00:10:55.094 INFO: Load active rules (done) | time=654ms
00:10:55.140 DEBUG: Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.py
00:10:55.140 DEBUG: Declared extensions of language CSS were converted to sonar.lang.patterns.css : **/*.css,**/*.less,**/*.scss
00:10:55.140 DEBUG: Declared extensions of language Go were converted to sonar.lang.patterns.go : **/*.go
00:10:55.140 DEBUG: Declared extensions of language Kotlin were converted to sonar.lang.patterns.kotlin : **/*.kt
00:10:55.140 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.vue
00:10:55.141 DEBUG: Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx
00:10:55.141 DEBUG: Declared extensions of language Ruby were converted to sonar.lang.patterns.ruby : **/*.rb
00:10:55.141 DEBUG: Declared extensions of language Scala were converted to sonar.lang.patterns.scala : **/*.scala
00:10:55.141 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
00:10:55.141 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
00:10:55.141 DEBUG: Declared extensions of language HTML were converted to sonar.lang.patterns.web : **/*.html,**/*.xhtml,**/*.cshtml,**/*.vbhtml,**/*.aspx,**/*.ascx,**/*.rhtml,**/*.erb,**/*.shtm,**/*.shtml
00:10:55.141 DEBUG: Declared extensions of language JSP were converted to sonar.lang.patterns.jsp : **/*.jsp,**/*.jspf,**/*.jspx
00:10:55.142 DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
00:10:55.142 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl
00:10:55.142 DEBUG: Declared extensions of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc,**/*.module
00:10:55.142 DEBUG: Declared extensions of language VB.NET were converted to sonar.lang.patterns.vbnet : **/*.vb
00:10:55.144 DEBUG: Will ignore generated code
00:10:55.145 DEBUG: Will ignore generated code
00:10:55.145 INFO: Indexing files...
00:10:55.145 INFO: Project configuration:
00:10:55.145 INFO:   Excluded sources: libraries/**, ser/**
00:10:55.155 DEBUG: readpipe [git, --version],/usr/bin
00:10:55.167 DEBUG: readpipe may return 'git version 2.21.1 (Apple Git-122.3)'
00:10:55.168 DEBUG: remaining output:

00:10:55.168 DEBUG: readpipe [git, config, --system, --edit],/usr/bin
00:10:55.179 DEBUG: readpipe may return '/private/etc/gitconfig'
00:10:55.179 DEBUG: remaining output:

00:10:55.530 DEBUG: 7014 non excluded files in this Git repository
00:10:55.557 INFO: Load project repositories....inc' indexed with language 'php'  # REDACTED :P
00:10:56.657 INFO: 827 files indexed
00:10:56.657 INFO: 0 files ignored because of inclusion/exclusion patterns
00:10:56.657 INFO: 0 files ignored because of scm ignore settings
00:10:56.658 INFO: Quality profile for css: Sonar way
00:10:56.658 INFO: Quality profile for java: Sonar way
00:10:56.658 INFO: Quality profile for js: Sonar way
00:10:56.658 INFO: Quality profile for jsp: Sonar way
00:10:56.658 INFO: Quality profile for php: Sonar way
00:10:56.658 INFO: Quality profile for web: Sonar way
00:10:56.658 INFO: Quality profile for xml: Sonar way
00:10:56.658 INFO: ------------- Run sensors on module xxxxxx
00:10:56.717 INFO: Load metrics repository
00:10:56.742 DEBUG: GET 200 http://my-sonarqube-server-ip:9000/api/metrics/search?f=name,description,direction,qualitative,custom&ps=500&p=1 | time=25ms
00:10:56.750 INFO: Load metrics repository (done) | time=33ms
00:10:57.600 DEBUG: 'Import external issues report' skipped because one of the required properties is missing
00:10:57.601 DEBUG: 'Python Sensor' skipped because there is no related file in current project
00:10:57.602 DEBUG: 'Cobertura Sensor for Python coverage' skipped because there is no related file in current project
00:10:57.602 DEBUG: 'PythonXUnitSensor' skipped because there is no related file in current project
00:10:57.602 DEBUG: 'PylintSensor' skipped because there is no related file in current project
00:10:57.603 DEBUG: 'PylintImportSensor' skipped because there is no related file in current project
00:10:57.603 DEBUG: 'Import of Bandit issues' skipped because there is no related file in current project
00:10:57.603 DEBUG: 'Import of stylelint issues' skipped because one of the required properties is missing
00:10:57.603 DEBUG: 'SonarGo' skipped because there is no related file in current project
00:10:57.604 DEBUG: 'Go Unit Test Report' skipped because there is no related file in current project
00:10:57.604 DEBUG: 'Go Cover sensor for Go coverage' skipped because one of the required properties is missing
00:10:57.605 DEBUG: 'Import of go vet issues' skipped because there is no related file in current project
00:10:57.605 DEBUG: 'Import of Golint issues' skipped because there is no related file in current project
00:10:57.605 DEBUG: 'Import of GoMetaLinter issues' skipped because there is no related file in current project
00:10:57.605 DEBUG: 'Import of GolangCI-Lint issues' skipped because there is no related file in current project
00:10:57.605 DEBUG: 'Kotlin Sensor' skipped because there is no related file in current project
00:10:57.606 DEBUG: 'Import of detekt issues' skipped because there is no related file in current project
00:10:57.606 DEBUG: 'Import of Android Lint issues' skipped because one of the required properties is missing
00:10:57.606 DEBUG: 'SonarJS Coverage' skipped because one of the required properties is missing
00:10:57.607 DEBUG: 'Import of ESLint issues' skipped because one of the required properties is missing
00:10:57.607 DEBUG: 'TypeScript analysis' skipped because there is no related file in current project
00:10:57.607 DEBUG: 'Import of TSLint issues' skipped because one of the required properties is missing
00:10:57.607 DEBUG: 'Ruby Sensor' skipped because there is no related file in current project
00:10:57.608 DEBUG: 'Import of RuboCop issues' skipped because one of the required properties is missing
00:10:57.608 DEBUG: 'SimpleCov Sensor for Ruby coverage' skipped because there is no related file in current project
00:10:57.608 DEBUG: 'Scala Sensor' skipped because there is no related file in current project
00:10:57.608 DEBUG: 'Scoverage sensor for Scala coverage' skipped because one of the required properties is missing
00:10:57.609 DEBUG: 'Import of Scalastyle issues' skipped because there is no related file in current project
00:10:57.609 DEBUG: 'Import of Scapegoat issues' skipped because there is no related file in current project
00:10:57.609 DEBUG: 'C# Properties' skipped because there is no related file in current project
00:10:57.610 DEBUG: 'Import of Checkstyle issues' skipped because one of the required properties is missing
00:10:57.610 DEBUG: 'Import of PMD issues' skipped because one of the required properties is missing
00:10:57.610 DEBUG: 'Import of SpotBugs issues' skipped because one of the required properties is missing
00:10:57.610 DEBUG: 'Removed properties sensor' skipped because one of the required properties is missing
00:10:57.611 DEBUG: 'Flex' skipped because there is no related file in current project
00:10:57.611 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
00:10:57.611 DEBUG: 'SonarTS' skipped because there is no related file in current project
00:10:57.611 DEBUG: 'VB.NET Properties' skipped because there is no related file in current project
00:10:57.614 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
00:10:57.614 DEBUG: 'C#' skipped because there is no related file in current project
00:10:57.614 DEBUG: 'C# Tests Coverage Report Import' skipped because there is no related file in current project
00:10:57.614 DEBUG: '[Deprecated] C# Integration Tests Coverage Report Import' skipped because there is no related file in current project
00:10:57.615 DEBUG: 'C# Unit Test Results Import' skipped because there is no related file in current project
00:10:57.615 DEBUG: 'VB.NET' skipped because there is no related file in current project
00:10:57.615 DEBUG: 'VB.NET Tests Coverage Report Import' skipped because there is no related file in current project
00:10:57.615 DEBUG: '[Deprecated] VB.NET Integration Tests Coverage Report Import' skipped because there is no related file in current project
00:10:57.615 DEBUG: 'VB.NET Unit Test Results Import' skipped because there is no related file in current project
00:10:57.615 DEBUG: Sensors : JavaSquidSensor -> SonarCSS Metrics -> SonarCSS Rules -> JaCoCo XML Report Importer -> JavaScript analysis -> SurefireSensor -> JavaXmlSensor -> HTML -> XML Sensor -> PHP sensor -> Analyzer for "php.ini" files
00:10:57.616 INFO: Sensor JavaSquidSensor [java]
00:10:57.685 INFO: Configured Java source version (sonar.java.source): none
00:10:57.691 INFO: JavaClasspath initialization
00:10:57.697 INFO: ------------------------------------------------------------------------
00:10:57.697 INFO: EXECUTION FAILURE
00:10:57.697 INFO: ------------------------------------------------------------------------
00:10:57.698 INFO: Total time: 4.439s
00:10:57.727 INFO: Final Memory: 13M/88M
00:10:57.727 INFO: ------------------------------------------------------------------------

Hello,

That’s odd indeed. I suspect that you have one file somewhere that’s of interest to the Java analyzer.
You may try to find it, but I think a simpler olution would be to provide a dummy directory for sonar.java.binaries. Something like passing -Dsonar.java.binaries=/tmp should fix your problem.
The directory that you pass should exist but does not need to contain any compiled Java classes.

Regards,

Hi Olivier,

Thanks for the quick response! A little sleep and your reply prompted me to double check what was being included in the scan. I realized there was a libraries folder which must have had some Java files in it. So, instead of pointing it to a dummy dir for the java binaries, I was able to just exclude the libraries directory (which is all third-party stuff anyways) using -Dsonar.exclusions=path/to/libraries/folder. Thanks for your help!!

For the record, the fact that you were confused in the first place pointed to me that we could improve the message… I therefore created a ticket SONARJAVA-3313. I hope it will help to avoid similar confusion in the future.

Best,
Quentin