Issue java 14: java.lang.NoClassDefFoundError: java/util/jar/Pack200

We have a gradle build using plugin version 2.8.0.1969. We are transfering this project to a java 14 based build. When running the sonarqube task, we get an error: java.lang.NoClassDefFoundError: java/util/jar/Pack200.
The full error when running with the --stacktrace flag enabled:

Execution failed for task ':sonarqube'.
> java/util/jar/Pack200

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarqube'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:205)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:203)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:184)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.NoClassDefFoundError: java/util/jar/Pack200
        at org.sonar.scanner.bootstrap.PluginFiles.unpack200(PluginFiles.java:165)
        at org.sonar.scanner.bootstrap.PluginFiles.download(PluginFiles.java:108)
        at org.sonar.scanner.bootstrap.PluginFiles.get(PluginFiles.java:75)
        at org.sonar.scanner.bootstrap.ScannerPluginInstaller.loadPlugins(ScannerPluginInstaller.java:63)
        at org.sonar.scanner.bootstrap.ScannerPluginInstaller.installRemotes(ScannerPluginInstaller.java:46)
        at org.sonar.scanner.bootstrap.ScannerPluginRepository.start(ScannerPluginRepository.java:45)
        at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:26)
        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:1016)
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:121)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
        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(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy89.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.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:100)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:727)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:694)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:568)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:553)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:536)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:276)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:265)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:67)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:36)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:159)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:72)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:43)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:192)
        ... 30 more
Caused by: java.lang.ClassNotFoundException: java.util.jar.Pack200
        at org.sonarsource.scanner.api.internal.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)
        ... 122 more

It seems this class was removed as part of the java 14 release ( JEP ), so it should no longer be used.

7 Likes

and it comes with no surprise that maven plugin got the same issue:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project my-project: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar: java/util/jar/Pack200

Bumping this since it’s received no official response.

Quite surprised that it’s still an issue given that JDK14 is now GA, and the class in question has been deprecated since June 2018!

3 Likes

It is a plugin used to download the sonar plugin during the “local” analysis:

As it is used as acceptCompression in the HTTP Get request, I guess we can simply change it to gzip and have it working?

For what it’s worth – Java 8 and 11 are supported for SonarQube analysis, as described in the Requirements Documentation! No support is declared for other Java versions.

Generally, LTS versions of Java are targeted for compatability.

Yes… Java13 it is supported too. The problem is in this way Sonar is pushing limit on what we can use about language in new versions…
As it seems a little problem we could fix it :slight_smile:

1 Like

I have the same issues. Are there any plans to support OpenJDK 14?

ERROR: Error during SonarQube Scanner execution
java.lang.NoClassDefFoundError: java/util/jar/Pack200
  at org.sonar.scanner.bootstrap.PluginFiles.unpack200(PluginFiles.java:165)
  at org.sonar.scanner.bootstrap.PluginFiles.download(PluginFiles.java:108)
  at org.sonar.scanner.bootstrap.PluginFiles.get(PluginFiles.java:75)

There’s a big gap between “it works” and “it’s supported!”

No plans right now, but you’re always welcome to Suggest New Features

Yeah you are right… maybe Java 13 “it works” only without support. But we are analyzing our projets in Java 13 since the end on last year.
I guess you don’t need a new future request to follow the market… just do it as other players are doing !!

Have the same

  • sonarqube-gradle-plugin: version “2.8”
  • Travis build failed with error message:
...
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarqube'.
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:205)
 at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
...
Caused by: java.lang.NoClassDefFoundError: java/util/jar/Pack200
at org.sonar.scanner.bootstrap.PluginFiles.unpack200(PluginFiles.java:165)
at org.sonar.scanner.bootstrap.PluginFiles.download(PluginFiles.java:108)
at org.sonar.scanner.bootstrap.PluginFiles.get(PluginFiles.java:75)
...

more details here

  • steps to reproduce
  1. gradle 6.3
  2. jdk 14 (openjdk)
  3. use --enable-preview flag
  4. create record
  5. ./gradlew sonarqube

commit with changes available here

  • potential workaround
    Remove usage Pack200 in PluginFiles (sonar-scanner-engine)
1 Like

It’s supported by compiling the sonarjava project, changing in the pom.xml file the asm version:
<asm.version>7.3.1</asm.version>

and then: mvn clean package -DskipTests=true

Switch expressions, pattern matching and text blocks are not supported yet, I can see, and will raise code smells, but I can live with this

Ran into this issue today as well. Sonar is now the only thing blocking us from upgrading our projects to Java 14.

Any workarounds for how a Java 14 project could be analyzed with Gradle Sonar plugin (we are using SonarCloud)?

Seems that Pack200 issue might be solved by somehow removing acceptCompression query param from the request. Not sure if that can be easily done. Maybe by using a temporarily forked copy of https://github.com/SonarSource/sonar-scanner-gradle?

And then there should be some way to force sonar plugin to use ASM 7.2+ dependency (https://asm.ow2.io/versions.html). Or should that happen on the server side, and there is nothing that can be done until official support is added?

1 Like

The use of pack200 is controlled by a component coming from the server side.
I’m afraid you’ll have to wait for official support.

We will fix the problem with pack200 but keep in mind that’s no guarantee that SonarQube/SonarCloud will be compatible with Java 14. Currently we don’t support Java 14 and we don’t run any tests with it.

https://jira.sonarsource.com/browse/SONAR-13314

4 Likes

@dmeneses I see SONAR-13314 is now resolved - thanks for a quick turnaround!

Is there some way to know when this fix will propagate to SonarCloud, so we could check if we can upgrade now?

1 Like

We’re evaluating SonarCloud at the moment and the first thing we saw is that this fails becuase of the mentioned issue. @dmeneses Can we expect the fix to be implemented in SonarCloud anytime soon or will it take longer?

We can live with Java 14 not being officially supported, but if it’s not working at all, it would keep us from going anywhere beyond the evaluation phase.

1 Like

Facing the same problem with quite common OpenJDK14 + Gradle6.4 + TravisCI + SonarCloudPlugin2.8 toolchain (build log). It seems that SonarCloud’s issue is the only one preventing the chain from building the project successfully.

We don’t need the full-fledged support of Java 14 code analysis by SonarCloud as well, so that “just working somehow” would be enough for us at first. Thank you!

The issue has been fixed in SonarCloud.

5 Likes

I can confirm the previous NoClassDefFoundError issue is now resolved on SonarCloud - thank you very much!

Although analysis of Java 14 code still fails, now with the following exception:

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 58
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:195)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:162)
	at org.sonar.java.bytecode.se.MethodLookup.lookup(MethodLookup.java:68)
	at org.sonar.java.bytecode.se.MethodLookup.lookup(MethodLookup.java:60)
	at org.sonar.java.bytecode.se.BytecodeEGWalker.execute(BytecodeEGWalker.java:316)
	at org.sonar.java.bytecode.se.BytecodeEGWalker.getMethodBehavior(BytecodeEGWalker.java:293)

Seems that it is the outdated ASM dependency that is now the blocker.

2 Likes

A few releases away, but on our radar.

5 Likes