[OSGi] NoClassDefFoundError: com/google/inject/internal/util/$StackTraceElements

2,495 views
Skip to first unread message

Johannes Schneider

unread,
Feb 15, 2011, 12:01:54 PM2/15/11
to google-guice
Hi guys,

I am trying to use Guice within an OSGi context (Equinox).
Unfortunately, I get a NoClassDefFoundError. I am using Guice 3.0-rc2
from Maven central.

Any idea what the problem might be - or how I should/could solve it?

Of course I could catch the exception within my bundle...


Thanks,

Johannes

java.lang.NoClassDefFoundError:
com/google/inject/internal/util/$StackTraceElements
at com.google.inject.internal.Errors.formatInjectionPoint(Errors.java:697)
at com.google.inject.internal.Errors.formatSource(Errors.java:659)
at com.google.inject.internal.Errors.format(Errors.java:536)
at
com.google.inject.CreationException.getMessage(CreationException.java:48)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)
at java.lang.Throwable.toString(Throwable.java:343)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java:115)
at java.lang.Throwable.printStackTraceAsCause(Throwable.java:536)
at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545)
at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545)
at java.lang.Throwable.printStackTrace(Throwable.java:516)
at
org.eclipse.core.runtime.adaptor.EclipseLog.getStackTrace(EclipseLog.java:446)
at
org.eclipse.core.runtime.adaptor.EclipseLog.writeStack(EclipseLog.java:537)
at
org.eclipse.core.runtime.adaptor.EclipseLog.writeLog(EclipseLog.java:480)
at org.eclipse.core.runtime.adaptor.EclipseLog.log(EclipseLog.java:306)
at
org.eclipse.core.internal.runtime.PlatformLogWriter.logging(PlatformLogWriter.java:35)
at org.eclipse.core.internal.runtime.RuntimeLog.log(RuntimeLog.java:95)
at
org.eclipse.core.internal.runtime.InternalPlatform.log(InternalPlatform.java:711)
at org.eclipse.core.internal.runtime.Log.log(Log.java:56)
at
org.eclipse.ui.statushandlers.WorkbenchErrorHandler.handle(WorkbenchErrorHandler.java:80)
at
org.eclipse.ui.internal.WorkbenchErrorHandlerProxy.handle(WorkbenchErrorHandlerProxy.java:36)
at
org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:189)
at
org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:231)
at
org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:242)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:248)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at
org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActive(WorkbenchPage.java:4218)
at
org.eclipse.ui.internal.WorkbenchPage$18.runWithException(WorkbenchPage.java:3277)
at
org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at
org.eclipse.ui.internal.Workbench$31.runWithException(Workbench.java:1566)
at
org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2537)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
de.avat.service.platform.application.Application.start(Application.java:29)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

Stuart McCulloch

unread,
Feb 15, 2011, 12:16:39 PM2/15/11
to google...@googlegroups.com
On 15 February 2011 17:01, Johannes Schneider <mail...@cedarsoft.com> wrote:
Hi guys,

I am trying to use Guice within an OSGi context (Equinox).
Unfortunately, I get a NoClassDefFoundError. I am using Guice 3.0-rc2
from Maven central.

Any idea what the problem might be - or how I should/could solve it?

I've not seen this before and I've used both RC2 and Guice trunk with Eclipse - can you create a simple test project to recreate the error?


--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.




--
Cheers, Stuart

Christian Kütbach

unread,
May 21, 2014, 2:38:40 AM5/21/14
to google...@googlegroups.com
 We have the same Problem (running inside IBM Notes). 

Are there any solutions found, yet?


Regards,
Christian Kütbach

Stuart McCulloch

unread,
May 21, 2014, 3:08:50 AM5/21/14
to google-guice


On 21 May 2014 08:00, "Christian Kütbach" <ckue...@gmail.com> wrote:
>
>  We have the same Problem (running inside IBM Notes). 
>
> Are there any solutions found, yet?

The original poster didn't reply with details of how to recreate the error, exactly what versions were involved, etc.

If you can tell us exactly how to recreate this exception then it should be straightforward to track down and fix.

--
Cheers, Stuart

>
>
> Regards,
> Christian Kütbach

Thomas Broyer

unread,
May 21, 2014, 5:23:48 AM5/21/14
to google...@googlegroups.com
I had a similar exception when mixing extensions from Guice 3 with Guice 4.
In my project, I use Guice 4.0-beta4, but a few dependencies (namely Jukito and Closure Templates) use Guice 3.0 and bring guice-multibinding and guice-assistedinject in their version 3.0.
Because the jarjar-ing treatment changed between versions, they don't play well together, so I need to declare those transitive dependencies with version 4.0-beta4 in my POM's dependencyManagement.

Side not: it would be easier if there was a "BOM", i.e. a pom.xml that lists all the possible dependencies (Guice core and extensions) with the same version in a <dependencyManagement> section, so it can be used with <scope>import</scope> to make sure you don't have version mismatches when deps transitively bring Guice extensions. That pom.xml could be guice-parent for example, or a new com.google.inject:guice-bom.

Christian Kütbach

unread,
May 23, 2014, 5:49:43 AM5/23/14
to google...@googlegroups.com
We found the root-cause to our problem. (Just in case someone have the same issue).

Guice.createInjector(new ServiceModule()); // This line caused the error

The Stacktrace was not helpful at all. I did a remote-debug and got the root cause. It was a wrong implementation:

bind(ServiceInterface.class).to(ServiceImpl.class);

I forgot the @Inject annotation at the ServiceImpl().

During the debugsession I got a nice Stacktrace with all information I needed. Without remote debugging I got no information about the cause.


Regards, 
Christian Kütbach






Reply all
Reply to author
Forward
0 new messages