Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Install Bundles
Install Bundles [message #24396] Fri, 26 September 2008 10:05 Go to next message
Michael Heiss is currently offline Michael HeissFriend
Messages: 25
Registered: July 2009
Junior Member
Hi,

I am trying to install a plugin programmatically using the following code:

BundleContext context =
ResourcesPlugin.getPlugin().getBundle().getBundleContext();
String path = "reference:file:///"+workspace.getLocation()+"/"+name+"/";
Bundle bundle = context.installBundle(path);

Where name is the name of the plugin in my workspace.

This works fine, the plugin is beeing installed and i see it in the
Plugin-Registry. When i try to call bundle.start() then a ClassNotFound
exception is thrown. The classloader cannot find the activator class of
the new installed bundle.

How can i solve this?

BestRegards
Michael
Re: Install Bundles [message #24439 is a reply to message #24396] Fri, 26 September 2008 11:07 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
The problem is that bundles in the workspace has slightly different
structure when they are deployed. The bundle classes are located at the
root of the bundle, while they are in bin/ subfolder when the bundle is
being developed.

I'm not sure what you are trying to accomplish, but I think you should
pack your bundles before installing via installBundle() method. This is
done via Export -> Plug-in Development -> Deployable plug-ins and
fragments wizard. Perhaps, it is better to describe your goal and I'll
try to suggest how to do it properly?

Also, don't use any bundle context you can reach, it is not polite:) You
should have your own activator and use the BundleContext object passed
to it.

BR,
Danail

Michael Heiß wrote:
> Hi,
>
> I am trying to install a plugin programmatically using the following code:
>
> BundleContext context =
> ResourcesPlugin.getPlugin().getBundle().getBundleContext();
> String path = "reference:file:///"+workspace.getLocation()+"/"+name+"/";
> Bundle bundle = context.installBundle(path);
>
> Where name is the name of the plugin in my workspace.
>
> This works fine, the plugin is beeing installed and i see it in the
> Plugin-Registry. When i try to call bundle.start() then a ClassNotFound
> exception is thrown. The classloader cannot find the activator class of
> the new installed bundle.
>
> How can i solve this?
>
> BestRegards
> Michael
>
Re: Install Bundles [message #24480 is a reply to message #24439] Fri, 26 September 2008 11:29 Go to previous messageGo to next message
Michael Heiss is currently offline Michael HeissFriend
Messages: 25
Registered: July 2009
Junior Member
Hi,

I have written a plugin that shows some data that is contributed with
extension points. Now i have the requirements that i have to add new
plugins (that use this extension point) during the application is running.

The plugins are stored in the workspace (and are modified during the
application is running) and now i try to load the plugins dynamically so
that they contribute the extensions and i can show the new data.
I hope it is clear what i try to do :)

Michael
Re: Install Bundles [message #24562 is a reply to message #24480] Mon, 29 September 2008 07:58 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
Perhaps you should use org.eclipse.pde.internal.ui.build.PluginExportJob
class to package the plugins before installing them. This will guarantee
you that the classes are available. Note that the class is in internal
package.


Michael Heiß wrote:
> Hi,
>
> I have written a plugin that shows some data that is contributed with
> extension points. Now i have the requirements that i have to add new
> plugins (that use this extension point) during the application is running.
>
> The plugins are stored in the workspace (and are modified during the
> application is running) and now i try to load the plugins dynamically so
> that they contribute the extensions and i can show the new data.
> I hope it is clear what i try to do :)
>
> Michael
>
Re: Install Bundles [message #24602 is a reply to message #24562] Mon, 29 September 2008 08:59 Go to previous message
Michael Heiss is currently offline Michael HeissFriend
Messages: 25
Registered: July 2009
Junior Member
Danail Nachev wrote:
> The problem is that bundles in the workspace has slightly different
> structure when they are deployed. The bundle classes are located at the
> root of the bundle, while they are in bin/ subfolder when the bundle is
> being developed.

Thanks for that hint :)
Now i dynamically create a jar file and then install this jar file, that
works perfect.

Just for the case somebody else wants to do the same:
I found that help topic to create a jar file:
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.jdt.doc.isv/guide/jdt_api_write_jar_file.htm
And i write the jar file using JarWriter3.

After the jar file is created i install i using:
String projectJarFile = workspace.getLocation() +"/myjar.jar";
BundleContext context =
Activator.getDefault().getBundle().getBundleContext();
Bundle bundle = context.installBundle(reference:file:///"+projectJarFile);
bundle.start();
Re: Install Bundles [message #581731 is a reply to message #24396] Fri, 26 September 2008 11:07 Go to previous message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
The problem is that bundles in the workspace has slightly different
structure when they are deployed. The bundle classes are located at the
root of the bundle, while they are in bin/ subfolder when the bundle is
being developed.

I'm not sure what you are trying to accomplish, but I think you should
pack your bundles before installing via installBundle() method. This is
done via Export -> Plug-in Development -> Deployable plug-ins and
fragments wizard. Perhaps, it is better to describe your goal and I'll
try to suggest how to do it properly?

Also, don't use any bundle context you can reach, it is not polite:) You
should have your own activator and use the BundleContext object passed
to it.

BR,
Danail

Michael Heiß wrote:
> Hi,
>
> I am trying to install a plugin programmatically using the following code:
>
> BundleContext context =
> ResourcesPlugin.getPlugin().getBundle().getBundleContext();
> String path = "reference:file:///"+workspace.getLocation()+"/"+name+"/";
> Bundle bundle = context.installBundle(path);
>
> Where name is the name of the plugin in my workspace.
>
> This works fine, the plugin is beeing installed and i see it in the
> Plugin-Registry. When i try to call bundle.start() then a ClassNotFound
> exception is thrown. The classloader cannot find the activator class of
> the new installed bundle.
>
> How can i solve this?
>
> BestRegards
> Michael
>
Re: Install Bundles [message #581739 is a reply to message #24439] Fri, 26 September 2008 11:29 Go to previous message
Michael Heiss is currently offline Michael HeissFriend
Messages: 25
Registered: July 2009
Junior Member
Hi,

I have written a plugin that shows some data that is contributed with
extension points. Now i have the requirements that i have to add new
plugins (that use this extension point) during the application is running.

The plugins are stored in the workspace (and are modified during the
application is running) and now i try to load the plugins dynamically so
that they contribute the extensions and i can show the new data.
I hope it is clear what i try to do :)

Michael
Re: Install Bundles [message #581805 is a reply to message #24480] Mon, 29 September 2008 07:58 Go to previous message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
Perhaps you should use org.eclipse.pde.internal.ui.build.PluginExportJob
class to package the plugins before installing them. This will guarantee
you that the classes are available. Note that the class is in internal
package.


Michael Heiß wrote:
> Hi,
>
> I have written a plugin that shows some data that is contributed with
> extension points. Now i have the requirements that i have to add new
> plugins (that use this extension point) during the application is running.
>
> The plugins are stored in the workspace (and are modified during the
> application is running) and now i try to load the plugins dynamically so
> that they contribute the extensions and i can show the new data.
> I hope it is clear what i try to do :)
>
> Michael
>
Re: Install Bundles [message #581826 is a reply to message #24562] Mon, 29 September 2008 08:59 Go to previous message
Michael Heiss is currently offline Michael HeissFriend
Messages: 25
Registered: July 2009
Junior Member
Danail Nachev wrote:
> The problem is that bundles in the workspace has slightly different
> structure when they are deployed. The bundle classes are located at the
> root of the bundle, while they are in bin/ subfolder when the bundle is
> being developed.

Thanks for that hint :)
Now i dynamically create a jar file and then install this jar file, that
works perfect.

Just for the case somebody else wants to do the same:
I found that help topic to create a jar file:
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.jdt.doc.isv/guide/jdt_api_write_jar_file.htm
And i write the jar file using JarWriter3.

After the jar file is created i install i using:
String projectJarFile = workspace.getLocation() +"/myjar.jar";
BundleContext context =
Activator.getDefault().getBundle().getBundleContext();
Bundle bundle = context.installBundle(reference:file:///"+projectJarFile);
bundle.start();
Previous Topic:Where to include cheatsheets?
Next Topic:Problem embedding jre with headless PDE-Build
Goto Forum:
  


Current Time: Fri Apr 26 21:24:52 GMT 2024

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

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

Back to the top