codingwell / scala-guice

Scala extensions for Google Guice
Apache License 2.0
341 stars 44 forks source link

java.lang.NoClassDefFoundError: net/codingwell/scalaguice/InternalModule$BindingBuilder #67

Closed abhsrivastava closed 6 years ago

abhsrivastava commented 6 years ago

My project uses guice 4.0.1 My project was working correctly until one of the libraries which I use evicted the 4.0.1 version with 4.1.0

And now my project gets an error

Exception in thread "main" java.lang.NoClassDefFoundError: net/codingwell/scalaguice/InternalModule$BindingBuilder
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:132)
    at com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:123)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:349)
    at com.google.inject.AbstractModule.install(AbstractModule.java:122)
    at com.foo.MainModule.configure(MainModule.scala:18)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
    at com.google.inject.spi.Elements.getElements(Elements.java:110)
    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:73)
    at com.foo.FooInjector$.initializeWith(FooInjector.scala:35)
    at com.foo.FooInjector$.initialize(FooInjector.scala:26)
    at com.foo.Foo$.main(Foo.scala:43)
    at com.foo.Foo.main(Foo.scala)
Caused by: java.lang.ClassNotFoundException: net.codingwell.scalaguice.InternalModule$BindingBuilder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I am not sure if there is a migration path from 4.0.1 to 4.1.0? what changes are required to be made to the code so that it works with 4.1.0?

abhsrivastava commented 6 years ago

I did analysis with sbt dependencyTree and found that the issue was other way round. my project was actually using 4.1.0 and the library downgraded it to 4.0.1 that is why the code stopped to work. Sorry for reporting the issue incorrectly.