Batch/file?name=template.jar is not valid: [404]

SonarQube version:8.8.42792
SonarScanner version: 4.5/4.6
code analysis: C code project

Hi all,

My sonarQube server had run perfectly for a while, till I try to add LDAP setting for authentication yesterday, and then, all analysis execute by Sonar-scanner failed.
Even after I revers the configuration then, SonarQube still returns with fail.

the log output here is

14:01:20.049 INFO: Project root configuration file: NONE
14:01:20.087 INFO: SonarScanner 4.6.0.2311
14:01:20.087 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
14:01:20.088 INFO: Linux 4.15.0-128-generic amd64
14:01:20.282 DEBUG: keyStore is :
14:01:20.282 DEBUG: keyStore type is : pkcs12
14:01:20.283 DEBUG: keyStore provider is :
14:01:20.283 DEBUG: init keystore
14:01:20.283 DEBUG: init keymanager of type SunX509
14:01:20.432 DEBUG: Create: /home/sonar/.sonar/cache
14:01:20.433 INFO: User cache: /home/sonar/.sonar/cache
14:01:20.433 DEBUG: Create: /home/sonar/.sonar/cache/_tmp
14:01:20.436 DEBUG: Extract sonar-scanner-api-batch in temp...
14:01:20.440 DEBUG: Get bootstrap index...
14:01:20.440 DEBUG: Download: http://localhost/sq/batch/index
14:01:20.513 DEBUG: Get bootstrap completed
14:01:20.519 DEBUG: Download http://localhost/sq/batch/file?name=template.jar to /home/sonar/.sonar/cache/_tmp/fileCache13789044267675696040.tmp
14:01:20.528 ERROR: SonarQube server [http://localhost/sq] can not be reached
14:01:20.529 INFO: ------------------------------------------------------------------------
14:01:20.530 INFO: EXECUTION FAILURE
14:01:20.530 INFO: ------------------------------------------------------------------------
14:01:20.530 INFO: Total time: 0.515s
14:01:20.547 INFO: Final Memory: 3M/17M
14:01:20.547 INFO: ------------------------------------------------------------------------
14:01:20.547 ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
        at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Status returned by url [http://localhost/sq/batch/file?name=template.jar] is not valid: [404]
        at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:118)
        at org.sonarsource.scanner.api.internal.ServerConnection.downloadFile(ServerConnection.java:80)
        at org.sonarsource.scanner.api.internal.JarDownloader$ScannerFileDownloader.download(JarDownloader.java:73)
        at org.sonarsource.scanner.api.internal.cache.FileCache.download(FileCache.java:98)
        at org.sonarsource.scanner.api.internal.cache.FileCache.get(FileCache.java:84)
        at org.sonarsource.scanner.api.internal.JarDownloader.lambda$getScannerEngineFiles$0(JarDownloader.java:60)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
        at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:61)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
        ... 7 more

Seems the problem occurred when the scanner tries to get the .jar file with batch/index, but there are two lines when browsing http://localhost/batch/index like this:

template.jar|****
scanner-developer-8.8.0.42792-all.jar|****

If use wget to grab the first template.jar file ,I got 404 error

wget http://localhost/sq/batch/file?name=template.jar 

Guess sonar-scanner couldn’t download the correct file from the URL and cause the error.


With followed command, I can successfully download the .jar file.

wget http://localhost/sq/batch/file?name=scanner-developer-8.8.0.42792-all.jar

how to fix this problem??

Hey there.

Something isn’t quite right here. Can you (in this order0

  • List the contents of your $SONARQUBE_HOME/lib/scanner/ directory
  • Do a full restart of your SonarQube instance (restarting the service, or running ./sonar.sh restart) and see if the problem persists?

Hi, thanks for replying,

Here is the results

$ ls -w 1 /opt/sonarqube-8.8.0.42792/lib/scanner/
META-INF
about.html
ch
com
de
google
javax
kotlin
module-info.class
net
okhttp3
okio
org
plugin.properties
scanner-developer-8.8.0.42792-all.jar
sonar-api-version.txt
sonar-edition.txt
sq-version.txt
sqljet.build.properties
svnkit.build.properties

I now update SonarQube to 8.9 and now the system work normally, but still curious about the issue.

The only file that should have been in that folder was *scanner-developer-8.8.0.42792-all.jar

Something went pretty wildly wrong in your setup – but I wouldn’t worry about it too much unless it happens again. Glad to hear you made it to SonarQube v8.9 LTS

OK,

Thanks for the answer. :smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.