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

NoClassDefFoundError: com/google/inject/ProvisionException #3897

Closed
djh82 opened this issue May 9, 2023 · 9 comments
Closed

NoClassDefFoundError: com/google/inject/ProvisionException #3897

djh82 opened this issue May 9, 2023 · 9 comments

Comments

@djh82
Copy link

djh82 commented May 9, 2023

Using ErrorProne 2.19.0 with the latest dataflow Jar (3.34), ProvisionException does not appear to be on the classpath.

The stacktrace is as follows (I can't get you the full one, sorry!):

error-prone version: 2.19.0
BugPattern: (see stack trace)
Stack Trace:
java.lang.NoClassDefFoundError: com/google/inject/ProvisionException
    at com.google.errorprone.scanner.ScannerSupplierImpl.instantiateChecker(ScannerSupplierImpl.java:64)
@cushon
Copy link
Collaborator

cushon commented May 9, 2023

@djh82 can you share a stack trace, or a repro? Which dataflow version are you using?

@cushon
Copy link
Collaborator

cushon commented May 9, 2023

Thanks, can you try with 3.27.0? That's the one we're building and testing against currently:

<dataflow.version>3.27.0</dataflow.version>

@djh82
Copy link
Author

djh82 commented May 10, 2023

Thanks, can you try with 3.27.0? That's the one we're building and testing against currently:

<dataflow.version>3.27.0</dataflow.version>

As expected, this also doesnt work.

@cushon
Copy link
Collaborator

cushon commented May 10, 2023

Sorry, I got distracted by the mention of dataflow, it makes sense that's unrelated to the missing ProvisionException.

The latest versions are using ProvisionException directly:

There is a testonly dep on it here, which might be preventing it from being included in the -with-deps jar:

error-prone/core/pom.xml

Lines 182 to 183 in 7335ba2

<version>${guice.version}</version>
<scope>test</scope>

@syskin345
Copy link

syskin345 commented May 15, 2023

Hi, is there a workaround?

I tried adding guice 5.1.0 to the compiler preprocessor jars and got "Failed to find an injectable constructor for AlwaysThrows requested by AlwaysThrows", and now I don't know if I'm doing it wrong or if I'm hitting the underlying reason why the ProvisionException is being loaded.

@lgemeinhardt
Copy link

lgemeinhardt commented May 25, 2023

I have the problem (via ant and using Java 11 and 17) and see the same error message "Failed to find an injectable constructor for AlwaysThrows requested by AlwaysThrows" ... if I disable this check, then then next pops up "Failed to find an injectable constructor for CheckReturnValue requested by CheckReturnValue" (stacktraces below)

May this commit 01e7503 makes the constructor invisible?

Stacktraces:

  [javac] java.lang.AssertionError: com.google.inject.ProvisionException: Unable to provision, see the following errors:
    [javac] 1) Failed to find an injectable constructor for CheckReturnValue requested by CheckReturnValue
    [javac] 1 error
    [javac] ======================
    [javac] Full classname legend:
    [javac] ======================
    [javac] CheckReturnValue: "com.google.errorprone.bugpatterns.CheckReturnValue"
    [javac] ========================
    [javac] End of classname legend:
    [javac] ========================
    [javac] 	at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:85)
    [javac] 	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:183)
    [javac] 	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
    [javac] 	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
    [javac] 	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
    [javac] 	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
    [javac] Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
    [javac] 1) Failed to find an injectable constructor for CheckReturnValue requested by CheckReturnValue
    [javac] 1 error
    [javac] ======================
    [javac] Full classname legend:
    [javac] ======================
    [javac] CheckReturnValue: "com.google.errorprone.bugpatterns.CheckReturnValue"
    [javac] ========================
    [javac] End of classname legend:
    [javac] ========================
    [javac] 	at com.google.errorprone.scanner.ErrorProneInjector.lambda$getInstance$0(ErrorProneInjector.java:72)
    [javac] 	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    [javac] 	at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:66)
    [javac] 	at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:55)
    [javac] 	at com.google.errorprone.scanner.ScannerSupplierImpl.instantiateChecker(ScannerSupplierImpl.java:66)
    [javac] 	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    [javac] 	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    [javac] 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    [javac] 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    [javac] 	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    [javac] 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    [javac] 	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    [javac] 	at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:74)
    [javac] 	at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:37)
    [javac] 	at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:80)
    [javac] 	... 10 more

copybara-service bot pushed a commit that referenced this issue May 25, 2023
to simplify dependency requirements for OSS.

#3897

PiperOrigin-RevId: 535265714
copybara-service bot pushed a commit that referenced this issue May 25, 2023
to simplify dependency requirements for OSS.

#3897

PiperOrigin-RevId: 535265714
copybara-service bot pushed a commit that referenced this issue May 25, 2023
to simplify dependency requirements for OSS.

#3897

PiperOrigin-RevId: 535265714
copybara-service bot pushed a commit that referenced this issue May 25, 2023
to simplify dependency requirements for OSS.

#3897

PiperOrigin-RevId: 535289068
@lgemeinhardt
Copy link

Short update regarding the "Failed to find an injectable constructor" problem - after reading #3931 and the linked PR https://github.com/PicnicSupermarket/error-prone-support/pull/621/files (including adding https://search.maven.org/artifact/javax.inject/javax.inject/1/jar) I tried the same and it worked :-)
Not sure, why "javax.inject" is not part of the "with-dependencies" artifact, but adding it separately fixed it.

@cushon
Copy link
Collaborator

cushon commented Oct 8, 2023

Not sure, why "javax.inject" is not part of the "with-dependencies" artifact

I think this was an oversight, I will look at getting it included in the next release.

For anyone else who encounters this before then, adding https://repo1.maven.org/maven2/javax/inject/javax.inject/1/javax.inject-1.jar to the classpath should fix it.

copybara-service bot pushed a commit that referenced this issue Oct 10, 2023
copybara-service bot pushed a commit that referenced this issue Oct 10, 2023
@cushon
Copy link
Collaborator

cushon commented Oct 18, 2023

This is resolved in 2.23.0

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

No branches or pull requests

4 participants