Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » re-factoring rcp application structure(from one bundle to several bundles)
re-factoring rcp application structure [message #677368] Wed, 08 June 2011 10:15 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
Hi all,
I've developed an RCP application as a single huge plugin, now I'd like to open source it and to make it cleaner, so I decided to split it into different plugins, in order to separate and modularise functionalities and features.
The first step I did was to create a new project, called "WHR.lib" which is a plugin project without an activator and that includes all the jars required by my application. I exported the packages provided by such jars.
In the main project, "WHR.core", I removed all the jars and imported in the required plugins the WHR.lib project, and also added the dependecy to such project int he build path.
However I've got a problem when I launch the application from the plugin.xml:

!SESSION 2011-06-08 12:03:42.149 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_23
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_GB
Framework arguments:  -application WHR.core.application
Command-line arguments:  -application WHR.core.application -data /sviluppo/java/eclipseWorkspace/../runtime-WHR.core.application -dev file:/sviluppo/java/eclipseWorkspace/.metadata/.plugins/org.eclipse.pde.core/WHR.core.application/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog

!ENTRY org.eclipse.osgi 2 0 2011-06-08 12:03:47.208
!MESSAGE The activator whr.rcp.Activator for bundle WHR.core is invalid
!STACK 0
org.osgi.framework.BundleException: The activator whr.rcp.Activator for bundle WHR.core is invalid
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:157)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:751)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:408)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:238)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1193)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:160)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:874)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:189)
	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:368)
	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: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.ClassNotFoundException: whr.rcp.Activator
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:150)
	... 23 more
Root exception:
java.lang.ClassNotFoundException: whr.rcp.Activator
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:150)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:751)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:408)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:238)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1193)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:160)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:874)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:189)
	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:368)
	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: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)

!ENTRY org.eclipse.osgi 4 0 2011-06-08 12:03:47.230
!MESSAGE Application error
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in WHR.core was unable to load class whr.rcp.Application.
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:180)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:162)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:874)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:189)
	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:368)
	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: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.ClassNotFoundException: whr.rcp.Application
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1193)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:160)
	... 16 more



The system alerts me that there are problems, and the problem view shows me the following:

Description	Resource	Path	Location	Type
classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath)	WHR.core		Unknown	Java Problem



However the lib project exports the org.aspectj.lang package and in the Java editor I don't see any error against the org.aspectj.lang imports. The following an excerpt of theexport section of the WHR.lib MANIFEST.MF

Export-Package: org.aopalliance.aop,
 org.aspectj.lang,


In the classpath section of the WHR.core project (the one I launch) I don't have anything, and I cannot specify the packages of the WHR.lib project. With regard to the running application I've got the following configuration:

<extension
         id="application"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run
               class="whr.rcp.Application">
         </run>
      </application>
   </extension>


and the manifest is

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: WHR.core
Bundle-SymbolicName: WHR.core;singleton:=true
Bundle-Version: 0.6.5.alpha
Bundle-Activator: whr.rcp.Activator
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.core.databinding;bundle-version="1.2.0",
 org.eclipse.jface.databinding;bundle-version="1.3.1",
 org.junit,
 WHR.lib;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: classes/,
 conf/,
 img/



And finally the following is the activator of WHR.core:

public class Activator extends AbstractUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "WHR.core";

	/**
	 * A global image registry for the application.
	 */
	private ImageRegistry imageRegistry = null;

	// The shared instance

	private static Activator plugin;
	public Activator() {
	}

	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	@Override
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);

		// clean the registry
		if( this.imageRegistry != null )
			this.imageRegistry.dispose();

		this.imageRegistry = null;
	}

	public static Activator getDefault() {
		return plugin;
	}



	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}


	@Override
	public synchronized final ImageRegistry getImageRegistry() {
		// return the value of the this.imageRegistry field
		return this.imageRegistry;
	}


	public synchronized final void setImageRegistry(ImageRegistry imageRegistry) {
		// set the value of the this.imageRegistry field
		this.imageRegistry = imageRegistry;
	}
}



Finally, I've tried to start the application with -clean, but nothing changed.
Anybody has a clue?

Thanks
Re: re-factoring rcp application structure [message #677423 is a reply to message #677368] Wed, 08 June 2011 13:19 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

First, what does the build.properties for WHR.core say? Your Bundle-ClassPath in your manifest looks fishy to me.

Secondly ... if your 3rd party jars don't already provide OSGi support, you should turn each one into bundle (you might have to do it to respect their licenses). That shouldn't stop your WHR.lib from working in general. You might have to go to each project, right click, and use PDE Tools>Update classpath to have them re-sync with each of their MANIFEST.MFs. Then a restart and a Project>Clean might not hurt Smile

PW


Re: re-factoring rcp application structure [message #678805 is a reply to message #677423] Thu, 09 June 2011 14:57 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
This is the build.properties files:

output.. = classes/
bin.includes = plugin.xml,\
               META-INF/,\
               classes/,\
               plugin_customization.ini,\
               img/,\
               splash.bmp,\
               src/,\
               conf/


I've recomputed the include path of each plugin but the error is still the same, and even the package explorer still reports the error that org.aspectj.lang.JoinPoint cannot be found.

I've checked and the project is configured as aspectj project. What has so strange my classpath?

Finally, I'll separate each jar into their own projects as soon as I can run it again.
Any suggestion is appreciated.
Thanks
Re: re-factoring rcp application structure [message #682115 is a reply to message #678805] Fri, 10 June 2011 12:50 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Your bin.includes isn't set up like a normal bundle. What about:

source.. = src/
output.. = classes/
bin.includes = plugin.xml,\
               META-INF/,\
               .,\
               plugin_customization.ini,\
               img/,\
               splash.bmp,\
               conf/



Bundle-ClassPath: .,
 conf/,
 img/


Why is conf and img in your bundle classpath? That means the are treated as roots for classloading. Putting the . everywhere will make sure it's included correctly.

However, I'm not sure why your project is in that shape to begin with. You mentioned using AspectJ, are you doing runtime weaving? Maybe that needs the src/ directory in your binary plugin, I don't know.



Re: re-factoring rcp application structure [message #998391 is a reply to message #682115] Wed, 09 January 2013 22:32 Go to previous message
Tux Pengy is currently offline Tux PengyFriend
Messages: 6
Registered: July 2012
Junior Member
Hey Luca,


I'm facing the same problem , After I exported my project as a product & running the .exe file.

I didn't face it before exporting but, now I do after adding -dev in program arguments
( not sure what it does)

Bye
Previous Topic:org.eclipse.ui.menus
Next Topic:Add the ProjectExplorer to an Eclipse e4 RCP Application
Goto Forum:
  


Current Time: Fri Apr 19 19:23:03 GMT 2024

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

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

Back to the top