Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Cannot access bundle or bundle context from within RAP plugin(Cannot access bundle or bundle context from within RAP plugin)
Cannot access bundle or bundle context from within RAP plugin [message #1775415] Mon, 30 October 2017 04:48
Clemens Gantert is currently offline Clemens GantertFriend
Messages: 6
Registered: August 2012
Location: CA, USA
Junior Member

I am looking for some pointers as to what I should look into to solve this strange behavior.
I have been trying to get a an RAP 3.1 based workbench application to run on Apache Karaf. The app has been running on equinox without issues. It's an OSGI deployment (no war). I finally got my RAP plugin (and all about 200 other bundles) to start, but I am having a hard time looking up other OSGI services from within the RAP plugin. I have never had this issue before and I can lookup these services from other bundles, but not the RAP bundle.

1) The following

returns always null. I debugged into getBundle() and the class loader of my class is different from the class loader of class BundleReference which is why it returns null.

2) If I save the bundle context from the activator's start() method in a static field and then try to lookup a service like
ServiceReference<PageMgr> pageMgrRef = UIActivator.bundleContext.getServiceReference(PageMgr.class);

then I get the following runtime exception:
java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) previously initiated loading for a different type with name "org/osgi/framework/BundleContext"        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(
        at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(
        at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(
        at org.eclipse.osgi.internal.loader.sources.MultiSourcePackage.loadClass(
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(

Bundle A provides the services I want to access from my RAP bundle B. I have a workaround by importing a class from a different bundle C into my RAP plugin and the imported class provides methods that lookup the services via bundle C's context. This works.
Any ideas why I cannot do this directly in the RAP bundle?

Previous Topic:Record Navigation Causes Whole Page Reloading
Next Topic: RAP in action
Goto Forum:

Current Time: Tue Oct 26 22:18:06 GMT 2021

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

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

Back to the top