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

java.lang.NoClassDefFoundError: com/google/common/base/Preconditions #11

Open
siddjain opened this issue Jul 23, 2022 · 0 comments
Open

Comments

@siddjain
Copy link

I get this error when I try to use this library:

java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
    at objectexplorer.InstrumentationGrabber.checkSetup (InstrumentationGrabber.java:20)
    at objectexplorer.InstrumentationGrabber.instrumentation (InstrumentationGrabber.java:25)
    at objectexplorer.MemoryMeasurer.<clinit> (MemoryMeasurer.java:24)
    at com.example.App.main (App.java:19)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:834)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Preconditions
    at jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:581)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:178)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
    at objectexplorer.InstrumentationGrabber.checkSetup (InstrumentationGrabber.java:20)
    at objectexplorer.InstrumentationGrabber.instrumentation (InstrumentationGrabber.java:25)
    at objectexplorer.MemoryMeasurer.<clinit> (MemoryMeasurer.java:24)
    at com.example.App.main (App.java:19)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:834)

Here is my setup:

  1. I am using mavenized version of this project that I downloaded from https://github.com/pluess/memory-measurer
  2. I use maven to run my application like this:
export MAVEN_OPTS=-javaagent:memory-measurer-1.0-SNAPSHOT.jar
mvn -e exec:java -Dexec.mainClass=com.example.App

I also tried packaging a fatjar and using that. That gives me another error:

---------------------------------------------------
constituent[0]: file:/Library/Downloads/apache-maven-3.8.5/conf/logging/
constituent[1]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-util-1.6.3.jar
constituent[2]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-builder-support-3.8.5.jar
constituent[3]: file:/Library/Downloads/apache-maven-3.8.5/lib/plexus-component-annotations-2.1.0.jar
constituent[4]: file:/Library/Downloads/apache-maven-3.8.5/lib/plexus-sec-dispatcher-2.0.jar
constituent[5]: file:/Library/Downloads/apache-maven-3.8.5/lib/slf4j-api-1.7.32.jar
constituent[6]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-core-3.8.5.jar
constituent[7]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-spi-1.6.3.jar
constituent[8]: file:/Library/Downloads/apache-maven-3.8.5/lib/plexus-utils-3.3.0.jar
constituent[9]: file:/Library/Downloads/apache-maven-3.8.5/lib/plexus-interpolation-1.26.jar
constituent[10]: file:/Library/Downloads/apache-maven-3.8.5/lib/plexus-cipher-2.0.jar
constituent[11]: file:/Library/Downloads/apache-maven-3.8.5/lib/jcl-over-slf4j-1.7.32.jar
constituent[12]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-model-builder-3.8.5.jar
constituent[13]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-embedder-3.8.5.jar
constituent[14]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-settings-3.8.5.jar
constituent[15]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-model-3.8.5.jar
constituent[16]: file:/Library/Downloads/apache-maven-3.8.5/lib/javax.annotation-api-1.2.jar
constituent[17]: file:/Library/Downloads/apache-maven-3.8.5/lib/commons-cli-1.4.jar
constituent[18]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-transport-wagon-1.6.3.jar
constituent[19]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-artifact-3.8.5.jar
#!/bin/bash
constituent[20]: file:/Library/Downloads/apache-maven-3.8.5/lib/wagon-file-3.5.1.jar
constituent[21]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-provider-3.8.5.jar
constituent[22]: file:/Library/Downloads/apache-maven-3.8.5/lib/org.eclipse.sisu.inject-0.3.5.jar
constituent[23]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-slf4j-provider-3.8.5.jar
constituent[24]: file:/Library/Downloads/apache-maven-3.8.5/lib/commons-io-2.6.jar
constituent[25]: file:/Library/Downloads/apache-maven-3.8.5/lib/wagon-http-3.5.1-shaded.jar
constituent[26]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-connector-basic-1.6.3.jar
constituent[27]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-api-1.6.3.jar
constituent[28]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-repository-metadata-3.8.5.jar
constituent[29]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-shared-utils-3.3.4.jar
constituent[30]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-plugin-api-3.8.5.jar
constituent[31]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-compat-3.8.5.jar
constituent[32]: file:/Library/Downloads/apache-maven-3.8.5/lib/org.eclipse.sisu.plexus-0.3.5.jar
constituent[33]: file:/Library/Downloads/apache-maven-3.8.5/lib/wagon-provider-api-3.5.1.jar
constituent[34]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-settings-builder-3.8.5.jar
constituent[35]: file:/Library/Downloads/apache-maven-3.8.5/lib/guice-4.2.2-no_aop.jar
constituent[36]: file:/Library/Downloads/apache-maven-3.8.5/lib/maven-resolver-impl-1.6.3.jar
constituent[37]: file:/Library/Downloads/apache-maven-3.8.5/lib/javax.inject-1.jar
constituent[38]: file:/Library/Downloads/apache-maven-3.8.5/lib/commons-lang3-3.8.1.jar
constituent[39]: file:/Library/Downloads/apache-maven-3.8.5/lib/jansi-2.4.0.jar
constituent[40]: file:/Library/Downloads/apache-maven-3.8.5/lib/guava-25.1-android.jar
---------------------------------------------------
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
	at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:341)
	at com.google.inject.Key.strategyFor(Key.java:335)
	at com.google.inject.Key.get(Key.java:219)
	at org.eclipse.sisu.wire.ParameterKeys.<clinit>(ParameterKeys.java:28)
	at org.eclipse.sisu.wire.DependencyAnalyzer.<init>(DependencyAnalyzer.java:93)
	at org.eclipse.sisu.wire.ElementAnalyzer.<init>(ElementAnalyzer.java:104)
	at org.eclipse.sisu.wire.WireModule.configure(WireModule.java:74)
	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
	at com.google.inject.spi.Elements.getElements(Elements.java:103)
	at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:481)
	at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:206)
	at org.apache.maven.cli.MavenCli.container(MavenCli.java:651)
#!/bin/bash
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
	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 java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

what gives?

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

1 participant