Can not debug java.lang.NoClassDefFoundError: com/

2019-03-06 02:33发布

I am trying to make an applet for uploading files to openstack swift using jclouds. And I am facing the NoClassDefFoundError, following is the stacktrace:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions
    at org.nnsoft.guice.rocoto.configuration.ConfigurationModule.configure(ConfigurationModule.java:64)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
    at com.google.inject.spi.Elements.getElements(Elements.java:101)
    at com.google.inject.spi.Elements.getElements(Elements.java:92)
    at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:52)
    at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:47)
    at org.jclouds.config.BindPropertiesToExpandedValues.configure(BindPropertiesToExpandedValues.java:47)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
    at com.google.inject.spi.Elements.getElements(Elements.java:101)
    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
    at com.google.inject.Guice.createInjector(Guice.java:95)
    at com.google.inject.Guice.createInjector(Guice.java:72)
    at com.google.inject.Guice.createInjector(Guice.java:62)
    at org.jclouds.ContextBuilder.expandProperties(ContextBuilder.java:385)
    at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:320)
    at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:620)
    at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:600)
    at com.cdac.appletclass.Test.main(Test.java:56)
Caused by: java.lang.ClassNotFoundException: com.google.inject.internal.util.$Preconditions
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 21 more

I googled for com/google/inject/internal/util/$Preconditions, and came to know that it is part of guice-3.0.jar. But guice-3.0.jar is already there in my project. How to debug then? any help..???

3条回答
一夜七次
2楼-- · 2019-03-06 02:54

Problem is solved now. It was a mistake between guice 3.0 and guice-3.0.0, because both are having the same maven artifact-id but group-id was different.

查看更多
Fickle 薄情
3楼-- · 2019-03-06 03:05

I suggest printing out what's on your classpath from within your app (see this answer). That way you'll know exactly what classpath your app is using, if there's anything missing or any collisions.

查看更多
4楼-- · 2019-03-06 03:11

enter image description here

Open the property of your project and add a dependency library.

查看更多
登录 后发表回答