mrszj / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Dependency on net.sf.cglib.core.NamingPolicy not declared in guice-assistedinject POM #589

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm currently running a project against Guice trunk 3.0 core and extensions out 
of SVN, building within Eclipse.

My app fails with a ClassNotFoundError which suggests that one of the guice 
subprojects, probably guice-assistedinject is not self-contained with respect 
to its dependencies.

This is a bugfix request to add the cglib dependency explicitly to relevant 
guice-* POM files.

I currently have only...
guice
guice-servlets
guice-persist
guice-multibindings
guice-assistedinject
...as project dependencies in my Eclipse project classpath.

Adding cglib to my own project POM through M2Eclipse is a workaround to fix the 
class loading error, shown in full below. 

>>>>>>>>>>>>>>

Exception in thread "main" java.lang.NoClassDefFoundError: 
net/sf/cglib/core/NamingPolicy
    at com.google.inject.assistedinject.FactoryProvider2.<init>(FactoryProvider2.java:284)
    at com.google.inject.assistedinject.FactoryModuleBuilder$1.configure(FactoryModuleBuilder.java:314)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
    at com.google.inject.AbstractModule.install(AbstractModule.java:118)
    at com.bt.labs.artemis.fsexample.FilesystemModule.configure(FilesystemModule.java:37)
    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:132)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
    at com.google.inject.Guice.createInjector(Guice.java:98)
    at com.google.inject.Guice.createInjector(Guice.java:72)
    at com.bt.labs.artemis.App.createInjector(App.java:52)
    at com.bt.labs.artemis.App.<init>(App.java:34)
    at com.bt.labs.artemis.servlet.EmbeddedJettyApp.<init>(EmbeddedJettyApp.java:23)
    at com.bt.labs.artemis.servlet.EmbeddedJettyApp.main(EmbeddedJettyApp.java:27)
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.core.NamingPolicy
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    ... 17 more

Original issue reported on code.google.com by google....@cefn.com on 14 Jan 2011 at 12:25

GoogleCodeExporter commented 9 years ago
Guice embeds its dependencies (other than aopalliance & jsr330) and isn't meant 
to be used as a dependency directly on its SVN contents.  If you do depend 
directly on SVN code (not recommended!), you need to also depend on lib & 
lib/build.  If you absolutely need to use the SVN code (because, say, you've 
patched it) and want to depend on Guice the "right way", then you need to build 
a distribution using 'ant dist' or 'mvn package'.  That will embed the 
dependencies (asm, cglib, hide com.google.inject.internal.util)

Original comment by sberlin on 14 Jan 2011 at 1:35

GoogleCodeExporter commented 9 years ago
Note: the current version of m2eclipse can have problems with projects which 
shade or jarjar their classes.
As a workaround, try closing the core guice project but keeping the extensions 
loaded - that should work.

Original comment by mccu...@gmail.com on 14 Jan 2011 at 4:28