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: 4
Registered: August 2012
Location: CA, USA
Junior Member
Hi,

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
FrameworkUtil.getBundle(SomeClassFromMyBundle.class)

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(ClassLoader.java:763)
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
        at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:327)
        at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:36)
        at org.eclipse.osgi.internal.loader.sources.MultiSourcePackage.loadClass(MultiSourcePackage.java:32)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:398)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
...


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?

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


Current Time: Thu May 24 08:23:09 GMT 2018

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

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

Back to the top