Problems with Guice in Eclipse: Class Loading Exceptions

441 views
Skip to first unread message

Anne Martens

unread,
Feb 24, 2009, 8:38:41 AM2/24/09
to Guice and OSGi
Dear Guice and OSGi group,

I'm trying to use the Opt4J optimization framework as a plugin in my
Eclipse application. Opt4J is a plain Java application that uses Guice
(i.e. hat the Guice jar on its classpath). I have put the Opt4J
sources in a plugin project, together with the guice-
snapshot20090205.jar, guice-multibindings-snapshot20090205.jar, and
aopalliance.jar. When trying to call Opt4J from my application, I get
the exceptions shown at the end of this message.

The Opt4J line calling Guice, in which the exceptions arise, is:

com.google.inject.Injector injector =
com.google.inject.Guice.createInjector(modules);
(org.opt4j.start.Opt4JTask.open(Opt4JTask.java:110) in the exceptions
below)

where modules is a List<com.google.inject.Module> containing Opt4J
specific subclasses of com.google.inject.AbstractModule.

I also tried putting the above-mentioned 3 Guice jars into an separate
plugin project, which didn't change anything.

Additionally, I added

-
Dorg.osgi.framework.bootdelegation=org.aopalliance.*,com.google.inject.*
-Dguice.custom.loader=true

to the VM arguments, without any effect.

I read on your wiki page that package-private types are problematic.
As far as I can see, the Opt4J classes involved are public (but I
might have missed something here, as it is not my code and I do not
exactly know how Guice is used).

Do you have any ideas what I could try? I'm also happy to provide more
information, if you need.

Thanks a lot in advance.

Kind regards,
Anne

The exceptions:

com.google.inject.internal.ComputationException:
com.google.inject.internal.ComputationException:
com.google.inject.internal.ComputationException:
com.google.inject.internal.ComputationException:
com.google.inject.internal.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:538)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:404)
at com.google.inject.internal.CustomConcurrentHashMap
$ComputingImpl.get(CustomConcurrentHashMap.java:2031)
at com.google.inject.internal.FailableCache.get(FailableCache.java:
46)
at com.google.inject.InjectorImpl$LateBoundConstructor.bind
(InjectorImpl.java:457)
at com.google.inject.ClassBindingImpl.initialize
(ClassBindingImpl.java:52)
at com.google.inject.InjectorImpl.initializeBinding(InjectorImpl.java:
347)
at com.google.inject.InjectorImpl.createJustInTimeBinding
(InjectorImpl.java:639)
at com.google.inject.InjectorImpl.createJustInTimeBindingRecursive
(InjectorImpl.java:584)
at com.google.inject.InjectorImpl.getJustInTimeBinding
(InjectorImpl.java:179)
at com.google.inject.InjectorImpl.getBindingOrThrow(InjectorImpl.java:
139)
at com.google.inject.InjectorImpl.getInternalFactory
(InjectorImpl.java:645)
at com.google.inject.FactoryProxy.notify(FactoryProxy.java:48)
at com.google.inject.BindingProcessor.runCreationListeners
(BindingProcessor.java:215)
at com.google.inject.InjectorBuilder.initializeStatically
(InjectorBuilder.java:131)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at com.google.inject.Guice.createInjector(Guice.java:92)
at com.google.inject.Guice.createInjector(Guice.java:69)
at org.opt4j.start.Opt4JTask.open(Opt4JTask.java:110)
at org.opt4j.start.Opt4JTask.execute(Opt4JTask.java:74)
at de.uka.ipd.sdq.dsexplore.opt4j.start.Opt4JStarter.startOpt4J
(Opt4JStarter.java:43)
at de.uka.ipd.sdq.dsexplore.launch.DSELaunch.launch(DSELaunch.java:
72)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch
(LaunchConfiguration.java:764)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch
(LaunchConfiguration.java:614)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch
(DebugUIPlugin.java:880)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run
(DebugUIPlugin.java:1083)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: com.google.inject.internal.ComputationException:
com.google.inject.internal.ComputationException:
com.google.inject.internal.ComputationException:
com.google.inject.internal.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:538)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:404)
at com.google.inject.internal.CustomConcurrentHashMap
$ComputingImpl.get(CustomConcurrentHashMap.java:2031)
at com.google.inject.internal.FailableCache.get(FailableCache.java:
46)
at com.google.inject.InjectorImpl$LateBoundConstructor.bind
(InjectorImpl.java:457)
at com.google.inject.ClassBindingImpl.initialize
(ClassBindingImpl.java:52)
at com.google.inject.InjectorImpl.initializeBinding(InjectorImpl.java:
347)
at com.google.inject.InjectorImpl.createJustInTimeBinding
(InjectorImpl.java:639)
at com.google.inject.InjectorImpl.createJustInTimeBindingRecursive
(InjectorImpl.java:584)
at com.google.inject.InjectorImpl.getJustInTimeBinding
(InjectorImpl.java:179)
at com.google.inject.InjectorImpl.getBindingOrThrow(InjectorImpl.java:
139)
at com.google.inject.InjectorImpl.createImplementedByBinding
(InjectorImpl.java:547)
at com.google.inject.InjectorImpl.createUnitializedBinding
(InjectorImpl.java:382)
at com.google.inject.InjectorImpl.createJustInTimeBinding
(InjectorImpl.java:638)
at com.google.inject.InjectorImpl.createJustInTimeBindingRecursive
(InjectorImpl.java:584)
at com.google.inject.InjectorImpl.getJustInTimeBinding
(InjectorImpl.java:179)
at com.google.inject.InjectorImpl.getBindingOrThrow(InjectorImpl.java:
139)
at com.google.inject.InjectorImpl.getInternalFactory
(InjectorImpl.java:645)
at com.google.inject.InjectorImpl.createParameterInjector
(InjectorImpl.java:737)
at com.google.inject.InjectorImpl.getParametersInjectors
(InjectorImpl.java:725)
at com.google.inject.ConstructorInjector.<init>
(ConstructorInjector.java:53)
at com.google.inject.InjectorImpl$5.create(InjectorImpl.java:753)
at com.google.inject.InjectorImpl$5.create(InjectorImpl.java:749)
at com.google.inject.internal.FailableCache$1.apply
(FailableCache.java:35)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:534)
... 26 more
Caused by: com.google.inject.internal.ComputationException:
com.google.inject.internal.ComputationException:
com.google.inject.internal.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:538)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:404)
at com.google.inject.internal.CustomConcurrentHashMap
$ComputingImpl.get(CustomConcurrentHashMap.java:2031)
at com.google.inject.internal.FailableCache.get(FailableCache.java:
46)
at com.google.inject.InjectorImpl$LateBoundConstructor.bind
(InjectorImpl.java:457)
at com.google.inject.ClassBindingImpl.initialize
(ClassBindingImpl.java:52)
at com.google.inject.InjectorImpl.initializeBinding(InjectorImpl.java:
347)
at com.google.inject.InjectorImpl.createJustInTimeBinding
(InjectorImpl.java:639)
at com.google.inject.InjectorImpl.createJustInTimeBindingRecursive
(InjectorImpl.java:584)
at com.google.inject.InjectorImpl.getJustInTimeBinding
(InjectorImpl.java:179)
at com.google.inject.InjectorImpl.getBindingOrThrow(InjectorImpl.java:
139)
at com.google.inject.InjectorImpl.getInternalFactory
(InjectorImpl.java:645)
at com.google.inject.InjectorImpl.createParameterInjector
(InjectorImpl.java:737)
at com.google.inject.InjectorImpl.getParametersInjectors
(InjectorImpl.java:725)
at com.google.inject.ConstructorInjector.<init>
(ConstructorInjector.java:53)
at com.google.inject.InjectorImpl$5.create(InjectorImpl.java:753)
at com.google.inject.InjectorImpl$5.create(InjectorImpl.java:749)
at com.google.inject.internal.FailableCache$1.apply
(FailableCache.java:35)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:534)
... 50 more
Caused by: com.google.inject.internal.ComputationException:
com.google.inject.internal.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:538)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:404)
at com.google.inject.internal.CustomConcurrentHashMap
$ComputingImpl.get(CustomConcurrentHashMap.java:2031)
at com.google.inject.ProxyFactory.get(ProxyFactory.java:68)
at com.google.inject.ConstructorInjector.<init>
(ConstructorInjector.java:52)
at com.google.inject.InjectorImpl$5.create(InjectorImpl.java:753)
at com.google.inject.InjectorImpl$5.create(InjectorImpl.java:749)
at com.google.inject.internal.FailableCache$1.apply
(FailableCache.java:35)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:534)
... 68 more
Caused by:
com.google.inject.internal.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
at com.google.inject.internal.cglib.core.AbstractClassGenerator.create
(AbstractClassGenerator.java:237)
at com.google.inject.internal.cglib.reflect.FastClass$Generator.create
(FastClass.java:64)
at com.google.inject.internal.BytecodeGen.newFastClass
(BytecodeGen.java:147)
at com.google.inject.DefaultConstructionProxyFactory$2.<init>
(DefaultConstructionProxyFactory.java:73)
at com.google.inject.DefaultConstructionProxyFactory.get
(DefaultConstructionProxyFactory.java:71)
at com.google.inject.ProxyFactory.createConstructionProxy
(ProxyFactory.java:85)
at com.google.inject.ProxyFactory$1.apply(ProxyFactory.java:62)
at com.google.inject.ProxyFactory$1.apply(ProxyFactory.java:60)
at com.google.inject.internal.MapMaker$StrategyImpl.compute
(MapMaker.java:534)
... 76 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.inject.internal.cglib.core.ReflectUtils.defineClass
(ReflectUtils.java:384)
at com.google.inject.internal.cglib.core.AbstractClassGenerator.create
(AbstractClassGenerator.java:219)
... 84 more
Caused by: java.lang.NoClassDefFoundError: com/google/inject/internal/
cglib/reflect/FastClass
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
... 90 more
Caused by: java.lang.ClassNotFoundException:
com.google.inject.internal.cglib.reflect.FastClass
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 92 more

Stuart McCulloch

unread,
Feb 24, 2009, 12:36:27 PM2/24/09
to guice...@googlegroups.com
2009/2/24 Anne Martens <annema...@googlemail.com>

Dear Guice and OSGi group,

Hi Anne,
 
I'm trying to use the Opt4J optimization framework as a plugin in my
Eclipse application. Opt4J is a plain Java application that uses Guice
(i.e. hat the Guice jar on its classpath). I have put the Opt4J
sources in a plugin project, together with the guice-
snapshot20090205.jar, guice-multibindings-snapshot20090205.jar, and
aopalliance.jar.

FYI, there is an outstanding issue with running certain Guice extensions on
OSGi because they currently share the com.google.inject.internal package:

   http://code.google.com/p/google-guice/issues/detail?id=311

but there is a patch you can apply (in the above issue) to fix this problem

however, from what you say above it sounds like you're embedding Guice
inside your plug-in (aka bundle) rather than using Guice as a plug-in in its
own right in the target platform (which is what I tend to do)

if you are embedding Guice and the multibinding extension together inside
your plug-in then issue 311 is not really applicable, because they'll be using
the same classloader (ie. your plug-in's classloader)

embedding Guice inside your plug-in is ok if it's just an internal dependency
(meaning you don't expose any Guice types via your public API) - however
if you do expose Guice types then it would probably be better simply to add
Guice (and the aopalliance bundle from peaberry*) to your target platform

* this is because the aopalliance jar provided with Guice is not an OSGi
  bundle, it's just the ordinary aopalliance jar (hmm, should Guice perhaps
  provide a bundlized version of aopalliance...?)

When trying to call Opt4J from my application, I get
the exceptions shown at the end of this message.

that's the same exception I get if I try to use AOP on a private type in OSGi
 
The Opt4J line calling Guice, in which the exceptions arise, is:

com.google.inject.Injector injector =
com.google.inject.Guice.createInjector(modules);
(org.opt4j.start.Opt4JTask.open(Opt4JTask.java:110) in the exceptions
below)

where modules is a List<com.google.inject.Module> containing Opt4J
specific subclasses of com.google.inject.AbstractModule.

I also tried putting the above-mentioned 3 Guice jars into an separate
plugin project, which didn't change anything.

it wouldn't - if it's the AOP issue then this won't have any effect
 
Additionally, I added

-
Dorg.osgi.framework.bootdelegation=org.aopalliance.*,com.google.inject.*
-Dguice.custom.loader=true

to the VM arguments, without any effect.

the bootdelegation setting would only have an effect if the Guice jar was on
your main application classpath (ie. if it was on the Eclipse boot classpath)

the guice.custom.loader setting is enabled by default, so this isn't a problem
 
I read on your wiki page that package-private types are problematic.
As far as I can see, the Opt4J classes involved are public (but I
might have missed something here, as it is not my code and I do not
exactly know how Guice is used).

Do you have any ideas what I could try? I'm also happy to provide more
information, if you need.

I'm going to take a look at Opt4J tomorrow to see if I can track down the
issue - hopefully I'll be able to fix it and upload a working plug-in example
 



--
Cheers, Stuart

Anne Martens

unread,
Mar 2, 2009, 8:27:12 AM3/2/09
to Guice and OSGi
Dear Stuart,

thanks a lot for your help.

Indeed, I only need Guice within a single plugin/bundle. That's why I
now put the three guice jars (guice-snapshot, guice-multibindings-
snapshot and aopalliance) back into the "referenced libraries" of my
opt4j wrapper plugin. I also tried to move the code starting Opt4J to
a new plugin activator class, that is activated when OSGi loads the
bundle.

Still, I get the same error (with a different stacktrace, of course):
(Opt4JStarter.java:41)
at Opt4JPluginActivator.<init>(Opt4JPluginActivator.java:9)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator
(AbstractBundle.java:141)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start
(BundleContextImpl.java:980)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker
(BundleHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start
(AbstractBundle.java:265).

the rest looks the same.

Do you have any suggestions what I could try? I am also happy to
provide my code if you need more details.

Kind regards,
Anne

On Feb 24, 6:36 pm, Stuart McCulloch <mccu...@gmail.com> wrote:
> 2009/2/24 Anne Martens <annemarte...@googlemail.com>
> ...
>
> read more »

Stuart McCulloch

unread,
Mar 2, 2009, 9:22:55 AM3/2/09
to guice...@googlegroups.com
2009/3/2 Anne Martens <annema...@googlemail.com>

Hi Anne,

actually if you could provide your code that would make the investigation go much faster :)

--
Thanks in advance, Stuart

Anne Martens

unread,
Mar 3, 2009, 3:53:27 AM3/3/09
to Guice and OSGi
Dear Stuart,

I have uploaded to code to http://sdqweb.ipd.uka.de/temp/org.opt4j-wrapper-plugin.zip.
You also find a .project file for Eclipse there. Currently, the plugin
needs org.eclipse.core.runtime for the plugin activator
Opt4JPluginActivator, but you can delete the class and the dependency
if you do not use Eclipse. To get the error, please call
de.uka.ipd.sdq.dsexplore.opt4j.start.Opt4JStarter.startOpt4J()

For configuration details, I also uploaded http://sdqweb.ipd.uka.de/temp/eclipse-config.txt,
which is a copy of the configuration details Eclipse provides
in Help -> About Eclipse Platform. I currently use version: 3.4.1build
id: M20080911-1700.

Thanks a lot! If you need more information, please let me know.

Kind regards,
Anne


On 2 Mrz., 15:22, Stuart McCulloch <mccu...@gmail.com> wrote:
> 2009/3/2 Anne Martens <annemarte...@googlemail.com>
> ...
>
> Erfahren Sie mehr »

Stuart McCulloch

unread,
Mar 3, 2009, 11:34:32 AM3/3/09
to guice...@googlegroups.com
2009/3/3 Anne Martens <annema...@googlemail.com>

Dear Stuart,

I have uploaded to code to http://sdqweb.ipd.uka.de/temp/org.opt4j-wrapper-plugin.zip.
You also find a .project file for Eclipse there. Currently, the plugin
needs org.eclipse.core.runtime for the plugin activator
Opt4JPluginActivator, but you can delete the class and the dependency
if you do not use Eclipse. To get the error, please call
de.uka.ipd.sdq.dsexplore.opt4j.start.Opt4JStarter.startOpt4J()

Hi Anne,

I tracked the exception down to a binding for a system type (java.util.Random)
in the OPT4J codebase that requires a constructor proxy - Guice checks with
the BytecodeGen utility class to decide whether it needs a bridge classloader
and it decides it doesn't for a system type, as mentioned in the Guice wiki:

   http://code.google.com/p/google-guice/wiki/ClassLoading

Unfortunately, the classloader then returned by BytecodeGen is not the Guice
classloader but the system classloader. Of course this does not have access
to the internal Guice AOP classes, and the injector blows up :(

I tried changing the OPT4J code to avoid the constructor proxy, but I couldn't
get round it without making major changes to the code, so you'll need to use
a patched version of Guice (at least until this is fixed in trunk)

A quick fix would be to remove the following check from BytecodeGen.java:

    if (delegate == getSystemClassLoaderOrNull()) {
      return delegate;
    }

Which would then enable bridging for system types - another option would be
to return the Guice class loader at this point instead of the system classloader:

    if (delegate == getSystemClassLoaderOrNull()) {
      return GUICE_CLASS_LOADER;
    }

Either of these would solve your problem, but they are not complete because
the Guice classloader won't have access to types in the system classloader
that don't reside in the "java" namespace (such as javax.* / org.omg.*) unless
of course you enabled OSGi bootdelegation for these packages...

I've coded up a solution that doesn't suffer from this and raised a Guice issue:

   http://code.google.com/p/google-guice/issues/detail?id=343

You can download a patched version of Guice here:

   http://code.google.com/p/peaberry/source/browse/trunk/lib/build/guice-customloader-20090303.jar

which avoids the AOP exception.

Not sure if this patch will make it into Guice 2 because it is in a critical piece
of code, and I don't want to put any undue pressure on Jesse who's already
done a lot of testing with the current code.

Are you ok using the patched build until this is fixed in an official release?




--
Cheers, Stuart

Anne Martens

unread,
Mar 3, 2009, 12:51:27 PM3/3/09
to Guice and OSGi
Dear Stuart,

thanks a lot for your fast reply! Yes, I'm absolutely ok with using a
patched version, I'm glad that there is a readily available solution.

I will try it and then let you know.

Kind regards
from a very happy Anne

On 3 Mrz., 17:34, Stuart McCulloch <mccu...@gmail.com> wrote:
> 2009/3/3 Anne Martens <annemarte...@googlemail.com>
>
>
>
> > Dear Stuart,
>
> http://code.google.com/p/peaberry/source/browse/trunk/lib/build/guice...
> ...
>
> Erfahren Sie mehr »

Anne Martens

unread,
Mar 3, 2009, 1:30:05 PM3/3/09
to Guice and OSGi
Dear Stuart,

I tried, but unfortunately ran into another error that looks similar
to the one before:

Error injecting method, java.lang.NoClassDefFoundError: com/google/
inject/internal/collect/Lists
at com.google.inject.multibindings.Multibinder
$RealMultibinder.initialize(Multibinder.java:254)
at org.opt4j.start.Opt4JModule.multi(Opt4JModule.java:128)

This was after I fixed a bug in my own code, which might be a reason
why you did not see it. I uploaded a fixed version of my code to the
url named above (http://sdqweb.ipd.uka.de/temp/org.opt4j-wrapper-
plugin.zip).

Is it possible that the guice-multibindings-....jar also needs a
patch? Or is it a problem that multibindings resides in its own jar?
For the latter, it might be an option to join the two into one jar.

Kind regards,
Anne
> ...
>
> Erfahren Sie mehr »

Stuart McCulloch

unread,
Mar 3, 2009, 1:42:44 PM3/3/09
to guice...@googlegroups.com
2009/3/4 Anne Martens <annema...@googlemail.com>

Dear Stuart,

I tried, but unfortunately ran into another error that looks similar
to the one before:

Error injecting method, java.lang.NoClassDefFoundError: com/google/
inject/internal/collect/Lists
 at com.google.inject.multibindings.Multibinder
$RealMultibinder.initialize(Multibinder.java:254)
 at org.opt4j.start.Opt4JModule.multi(Opt4JModule.java:128)

This was after I fixed a bug in my own code, which might be a reason
why you did not see it. I uploaded a fixed version of my code to the
url named above (http://sdqweb.ipd.uka.de/temp/org.opt4j-wrapper-
plugin.zip
).

Is it possible that the guice-multibindings-....jar also needs a
patch? Or is it a problem that multibindings resides in its own jar?
For the latter, it might be an option to join the two into one jar.

Note this is actually a different issue unrelated to the previous problem,
the issue here is that the multibindings extension uses classes from the
internal Guice package which (rightly) isn't exported

See http://code.google.com/p/google-guice/issues/detail?id=311

If you've got them inside the same Bundle-ClassPath (as you had before)
then it shouldn't matter because the internal package is only hidden from
other bundles / plug-in ... jars on the same Bundle-ClassPath will merge
together just like in a classic Java application

however, if you're using them as separate bundles then you'd need to
patch the multibindings jar to attach as a fragment to the Guice bundle
as suggested in Issue 311

I'll take a look at your updated code to see what's changed...




--
Cheers, Stuart

Stuart McCulloch

unread,
Mar 3, 2009, 2:14:48 PM3/3/09
to guice...@googlegroups.com
2009/3/4 Stuart McCulloch <mcc...@gmail.com>

Aha, found the problem - it's because the packaging of Google-Collection
classes inside Guice changed post-20090205... so when you use the old
multibindings jar with the new Guice jar there's a package mismatch.

In the 20090205 snapshot it was "com.google.inject.internal.common.Lists",
now it is "com.google.inject.internal.Lists" - if you build Guice multibindings
from trunk (or use the jar I'm going to send you) then everything should work




--
Cheers, Stuart

Anne Martens

unread,
Mar 4, 2009, 8:12:54 AM3/4/09
to Guice and OSGi
Dear Stuart,

now it is working, I was able to execute an evolutionary algorithm
with Opt4J and Guice inside my Eclipse plugin.

Thanks a lot again!

Cheers,
Anne

On 3 Mrz., 20:14, Stuart McCulloch <mccu...@gmail.com> wrote:
> 2009/3/4 Stuart McCulloch <mccu...@gmail.com>
>
>
>
> > 2009/3/4 Anne Martens <annemarte...@googlemail.com>
>
> >> Dear Stuart,
>
> >> I tried, but unfortunately ran into another error that looks similar
> >> to the one before:
>
> >> Error injecting method, java.lang.NoClassDefFoundError: com/google/
> >> inject/internal/collect/Lists
> >>  at com.google.inject.multibindings.Multibinder
> >> $RealMultibinder.initialize(Multibinder.java:254)
> >>  at org.opt4j.start.Opt4JModule.multi(Opt4JModule.java:128)
>
> >> This was after I fixed a bug in my own code, which might be a reason
> >> why you did not see it. I uploaded a fixed version of my code to the
> >> url named above (http://sdqweb.ipd.uka.de/temp/org.opt4j-wrapper-
> >> plugin.zip<http://sdqweb.ipd.uka.de/temp/org.opt4j-wrapper-%0Aplugin.zip>
> >> ).
>
> >> Is it possible that the guice-multibindings-....jar also needs a
> >> patch? Or is it a problem that multibindings resides in its own jar?
> >> For the latter, it might be an option to join the two into one jar.
>
> > Note this is actually a different issue unrelated to the previous problem,
> > the issue here is that the multibindings extension uses classes from the
> > internal Guice package which (rightly) isn't exported
>
> > Seehttp://code.google.com/p/google-guice/issues/detail?id=311
> ...
>
> Erfahren Sie mehr »
Reply all
Reply to author
Forward
0 new messages