Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » java.lang.IllegalAccessError: class cannot access its superclass
java.lang.IllegalAccessError: class cannot access its superclass [message #552527] Thu, 12 August 2010 14:08 Go to next message
Gaston M. Tonietti is currently offline Gaston M. ToniettiFriend
Messages: 7
Registered: July 2009
Junior Member
Hi all,

I have the following scenario, and I think my problem is related to osgi since in an osgiless server and in tests it is working but it breaks when running inside the RCP client.
I must extend a package-scoped class from a third-party lib so I've created the very same package in my bundle and created the extending class there. It works in non-osgi environments. So I don't know if I have to add any special header to my bundle manifest to have the access rights to the mentioned class.

I'm using Spring HttpInvokers and it happens when deserializing the response from the server within the RCP client.

com.google.common.collect.ChildrenMultimap is in my bundle and com.google.common.collect.AbstractSetMultimap which is default scope is in a separate bundle which mine depends on.

org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://localhost:8080/bom-server/remoting/LoginService]; nested exception is java.lang.IllegalAccessError: class com.google.common.collect.ChildrenMultimap cannot access its superclass com.google.common.collect.AbstractSetMultimap
at org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.convertHttpInvokerAccessException(HttpInvokerClien tInterceptor.java:211)
at org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation .proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke( JdkDynamicAopProxy.java:204)
at $Proxy9.login(Unknown Source)
at com.tc.bom.ui.dialog.LoginAndChooseAccountDialog.loginPresse d(LoginAndChooseAccountDialog.java:205)
at com.tc.bom.ui.dialog.LoginAndChooseAccountDialog.buttonPress ed(LoginAndChooseAccountDialog.java:280)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.jav a:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3493)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3112)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825 )
at org.eclipse.jface.window.Window.open(Window.java:801)
at com.tc.bom.ui.Application.login(Application.java:98)
at com.tc.bom.ui.Application.start(Application.java:74)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
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(EclipseS tarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.IllegalAccessError: class com.google.common.collect.ChildrenMultimap cannot access its superclass com.google.common.collect.AbstractSetMultimap
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.def ineClass(DefaultClassLoader.java:183)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineC lass(ClasspathManager.java:576)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findCla ssImpl(ClasspathManager.java:546)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClassImpl(ClasspathManager.java:477)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass_LockClassLoader(ClasspathManager.java:465)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:445)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:211)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass (BundleLoader.java:376)
at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadCla ss(SingleSourcePackage.java:33)
at org.eclipse.osgi.internal.loader.MultiSourcePackage.loadClas s(MultiSourcePackage.java:31)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInter nal(BundleLoader.java:449)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund leLoader.java:405)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund leLoader.java:393)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(Bund leLoader.java:321)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:231)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1193)
at org.springframework.osgi.util.BundleDelegatingClassLoader.fi ndClass(BundleDelegatingClassLoader.java:99)
at org.springframework.osgi.util.BundleDelegatingClassLoader.lo adClass(BundleDelegatingClassLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.springframework.util.ClassUtils.forName(ClassUtils.java: 211)
at org.springframework.core.ConfigurableObjectInputStream.resol veClass(ConfigurableObjectInputStream.java:56)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream .java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.ja va:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStrea m.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.j ava:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java: 351)
at java.util.ArrayList.readObject(ArrayList.java:593)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass .java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.j ava:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStrea m.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.j ava:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStrea m.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.j ava:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStrea m.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.j ava:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java: 351)
at org.springframework.remoting.httpinvoker.AbstractHttpInvoker RequestExecutor.doReadRemoteInvocationResult(AbstractHttpInv okerRequestExecutor.java:291)
at org.springframework.remoting.httpinvoker.AbstractHttpInvoker RequestExecutor.readRemoteInvocationResult(AbstractHttpInvok erRequestExecutor.java:242)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRe questExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecu tor.java:68)
at org.springframework.remoting.httpinvoker.AbstractHttpInvoker RequestExecutor.executeRequest(AbstractHttpInvokerRequestExe cutor.java:136)
at org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.executeRequest(HttpInvokerClientInterceptor.java:1 91)
at org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.executeRequest(HttpInvokerClientInterceptor.java:1 73)
at org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.invoke(HttpInvokerClientInterceptor.java:141)
... 28 more

Thank you very much.
Gaston.
Re: java.lang.IllegalAccessError: class cannot access its superclass [message #552546 is a reply to message #552527] Thu, 12 August 2010 15:27 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 437
Registered: July 2009
Senior Member
Keep in mind that in order to get package-scope access two classes must be in the same package AND loaded by the same class loader. In OSGi each bundle has its own class loader. So the two classes com.google.common.collect.ChildrenMultimap and com.google.common.collect.AbstractSetMultimap will not have package-scope access to each other unless they are loaded by the same class loader. In your case the two classes are in separate bundles and are NOT loaded by the same class loader.

In OSGi we have a concept of fragment bundles. You could package com.google.common.collect.ChildrenMultimap into a fragment that uses the original bundle (containing com.google.common.collect.AbstractSetMultimap) as its host. In OSGi fragment bundle classes are loaded by the same class loader as their host bundle, this allows com.google.common.collect.ChildrenMultimap to get package access to com.google.common.collect.AbstractSetMultimap.

HTH

Tom.
Re: java.lang.IllegalAccessError: class cannot access its superclass [message #552555 is a reply to message #552546] Thu, 12 August 2010 15:47 Go to previous message
Gaston M. Tonietti is currently offline Gaston M. ToniettiFriend
Messages: 7
Registered: July 2009
Junior Member
Your're right! Thank you so much for the quick answer. I will try it.

Thanks again.
Gaston.
Previous Topic:New dependency of p2 SDK?
Next Topic:P2 enabled RCP app: Updating doesn't update features/plugins
Goto Forum:
  


Current Time: Mon Nov 24 08:40:49 GMT 2014

Powered by FUDForum. Page generated in 0.02150 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software