Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » load plugin programmatically(load plugin if some condition is satisfied)
load plugin programmatically [message #549257] Mon, 26 July 2010 09:50 Go to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
Hi, I search the way to load plugin to my RPC when some condition is satisfied. I looked at org.eclipse.ui.tests.dynamicplugins.DynamicUtils and created a code like the following (eclipse3.4):
/** main plugin Application */
public class Application implements IApplication {
	public Object start(IApplicationContext context) {
	   BundleContext bundleContext = InternalPlatform.getDefault().getBundleContext();
  	   String location = "reference:file:/<fullpath to dynamic plugin dir>";
	   Bundle b = bundleContext.installBundle(location);
           // until now it is ok, Bundle b != null
	   try {
		// start the plugin explicitly
		b.start();
	    }
	...

It fails with
Quote:
BundleException: The activator org.mlnx.aria.trav.Activator for bundle org.mlnx.aria.trav is invalid...
Caused by: java.lang.ClassNotFoundException: org.mlnx.aria.trav.Activator

As I understand, the dynamic plugin is not in the classpath. I removed it from Run Configuration/Plugins in order to load it explicitly when it is needed.
How to activate the dynamic plugin correctly?
Thanks a lot. Stella
Re: load plugin programmatically [message #549303 is a reply to message #549257] Mon, 26 July 2010 12:14 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you clean your workspace and configuration area from your launch
config (make it like a first time startup) does it load your plugin?

Stella wrote:
>> try {
> // start the plugin explicitly
> b.start();
> }

Make sure you use b.start(Bundle.START_TRANSIENT) ... otherwise on the
next run, it will try and start the previous bundle.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: load plugin programmatically [message #549315 is a reply to message #549303] Mon, 26 July 2010 12:49 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
Hi Paul, thanks a lot for reply.
I made
Quote:
rm -rf <workspace>/.metadata
<start rcp> -clean

Also I changed the code to
	   try {
		// start the plugin explicitly
		b.start(Bundle.START_TRANSIENT);

and I still get the same exception.
Re: load plugin programmatically [message #549374 is a reply to message #549315] Mon, 26 July 2010 14:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Stella wrote:
> Hi Paul, thanks a lot for reply.
> I made Quote:
>> rm -rf <workspace>/.metadata
>> <start rcp> -clean
>
> Also I changed the code to try {
> // start the plugin explicitly
> b.start(Bundle.START_TRANSIENT);
> and I still get the same exception.

Does it work on a new clean workspace with a new clean configuration
area (for launch configs, you can set your launch config to clean the
launched workspace and launching config area)?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: load plugin programmatically [message #549602 is a reply to message #549374] Tue, 27 July 2010 11:01 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
Hi Paul, thanks for reply,
No, it does not work on a new clean workspace with a new clean configuration. I created new rpc release and new plugin release, they should have clean cofiguration. I made clean workspace. And it fails with the same exception. Stella
Re: load plugin programmatically [message #549633 is a reply to message #549602] Tue, 27 July 2010 11:53 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Stella wrote:
> Hi Paul, thanks for reply,
> No, it does not work on a new clean workspace with a new clean
> configuration. I created new rpc release and new plugin release, they
> should have clean cofiguration. I made clean workspace. And it fails
> with the same exception. Stella

The plugin you are trying to load is a directory? Is it the plugin in
your workspace?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: load plugin programmatically [message #549648 is a reply to message #549633] Tue, 27 July 2010 13:12 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
The plugin is a directory. I tried to load it when it is in the workspace and also I tried to load it when it is in release directory.
Re: load plugin programmatically [message #549656 is a reply to message #549648] Tue, 27 July 2010 13:30 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Stella wrote:
> The plugin is a directory. I tried to load it when it is in the
> workspace and also I tried to load it when it is in release directory.

In the workspace I'd be surprised if it worked. The shape of a plugin
in the workspace contains bundle entries at the root and class files in
the bin/ folder. If that's not specified in your Bundle-ClassPath in
you MANIFEST, you cannot load the bundle into your running eclipse.

Write a small bundle with an Activator that simply prints out Hello.
Try and use your code to load that.

Then if it doesn't work, you can tell us exactly what you did and we can
help.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: load plugin programmatically [message #549852 is a reply to message #549656] Wed, 28 July 2010 08:44 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
Hi Paul. Thanks a lot for reply. I created small plugin "Hello Word", export it and tried to install and start it in my rpc. I get the same exceptions.
Quote:
org.osgi.framework.BundleException: The activator test.Activator for bundle test is invalid
Caused by: java.lang.ClassNotFoundException: test.Activator

I checked that Activator.class is in jar file.
Also I tried to install and start in the same manner the plugin apache_xmlrpc_3.1.3 and I didn't get the exceptions. Stella
Re: load plugin programmatically [message #549900 is a reply to message #549852] Wed, 28 July 2010 12:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Stella wrote:
> Hi Paul. Thanks a lot for reply. I created small plugin "Hello Word",
> export it and tried to install and start it in my rpc. I get the same
> exceptions. Quote:

OK, create the RCP mail app, add your test bundle and export it. Now
from the RCP app add the code you expect to install and start your test
bundle.

If that doesn't work, then please open a bug (and now you can attach
your 2 test bundles).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: load plugin programmatically [message #550417 is a reply to message #549900] Fri, 30 July 2010 10:19 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
Thanks a lot Paul. The Bug 321321 https://bugs.eclipse.org/bugs/show_bug.cgi?id=321321
Re: load plugin programmatically [message #553697 is a reply to message #549257] Wed, 18 August 2010 14:07 Go to previous message
Stella Levin is currently offline Stella LevinFriend
Messages: 89
Registered: July 2009
Member
I get it working when use fullpath including jar:
String location =
"reference:file:<full path>/myplugin/plugins/myplugin_1.0.0.jar";
Bundle b = context.installBundle(location);
Thanks a lot.
Previous Topic:NullPointerException in ApplicationActionBarAdvisor
Next Topic:DragAndDrop in AbstractDecoratedTextEditor
Goto Forum:
  


Current Time: Thu Mar 28 13:08:49 GMT 2024

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

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

Back to the top