Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not create an instance of type com.github.spotbugs.internal.spotbugs.SpotBugsExecutor #120

Closed
aplotnikov opened this issue Mar 1, 2019 · 8 comments

Comments

@aplotnikov
Copy link

Hi all,

I am migrating my gradle project to the newest version - 5.0 -> 5.2.1.
In my project spotbug is used. The current version of spotbug plugin is 1.6.4, spotbug version is 3.1.8.
On the old version of gradle everything works fine. However on the new version I got such error.

* What went wrong:
Execution failed for task ':spotbugsMain'.
> Failed to run Gradle SpotBugs Worker
   > Could not create an instance of type com.github.spotbugs.internal.spotbugs.SpotBugsExecuter.
      > com.google.common.collect.ImmutableList.builderWithExpectedSize(I)Lcom/google/common/collect/ImmutableList$Builder;

I tried to update sportbug to version 3.1.12, plugin to version 1.6.10. However it didn't help.

Could you help?

@KengoTODA
Copy link
Member

I hope this comment helps your case. Could you check that?

@slovdahl
Copy link

slovdahl commented Mar 4, 2019

I have a hard time understanding what triggers this exception. Yes, we do use Guava 23.0 internally, but what code path is trying to use a method that's available from 23.1? It sure isn't coming from our own code.

FWIW, we're getting this error while trying to update Gradle 4.10.3 -> 5.2.1, SpotBugs 3.1.7 -> 3.1.12 and SpotBugs Gradle plugin 1.6.3 -> 1.6.10.

@KengoTODA
Copy link
Member

It sure isn't coming from our own code.

Could you make mcve project to reproduce this issue? It helps us to find why/how this problem is caused.

@slovdahl
Copy link

slovdahl commented Mar 4, 2019

Sorry, it looks like it was a false alarm with regard to SpotBugs. I was able to track it down to another Gradle plugin that depends on an ancient version of guava, version 18.0:

buildscript {
    dependencies {
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.6'
    }
}

The workaround was to force guava >= 23.0.1 to be on that same buildscript classpath.

It looks like it could be a bug in Gradle, where stuff on different classpaths may leak between contexts. However, I have no idea where the newer guava is leaking in.

Helpful references:

@aplotnikov
Copy link
Author

The project is private so I can not share it with you.

However what @slovdahl wrote helped me. I have added exclude for guava from the classpath and it helped me. I am not sure whether it is a good solution but at least some work around.

buildscript {
   configurations.classpath {
           exclude group: 'com.google.guava', module: 'guava'
   }
}

@JieLi-github
Copy link

Does this plugin depend on Guava? What should I do if I don't want to declare specifically Guave dependency in my build file?

@danello
Copy link

danello commented Sep 13, 2019

The nebula.lint plugin up through version 14.0.1 combined with spotbugs 2.0.0 induces this error. Just thought I would note that here in case someone else lands here like I did. Excluding guava from my config classpath using the block in @slovdahl's comment fixed the issue for me.

@michalborek
Copy link

michalborek commented Sep 27, 2019

In my case this workaround helped:

buildscript {
    dependencies {
        classpath group: 'com.google.guava', name: 'guava', version: '28.1-jre'
   }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants