Eclipse RCP: Plugin does not start - plugins

I wrote a new plugin for my eclipse rcp application and added the plugin to the dependencies of my product. I also tried to set the auto-start value of the new plugin to true but it does not start. It shows up as resolved but not as started.
Basically the only thing that this plugin does is to add a help file (table of contents) via the extension point org.eclipse.help.toc.
Any idea why the plugin code isn't executed?
Also: the plugin adds its content if I execute it from inside eclipse. The problem occures after I export it.

Just to be clear ... you're not expecting 'code' to run, but when you launch the exported RCP application standalone, the help contents does not appear in the TOC, right?
How did you define your RCP product? As a feature or plug-in based product?
If based on plug-in's, did you define all the necessary plug-in's on the product dependencies tab?
If based on features, did you add the new plug-in to the feature?

Related

Eclipse RCP plugin dependencies

I am trying to generate an RCP product from a set of Eclipse plugin. When I am trying to run the Eclipse plugin from my Eclipse.rcp.product plugin, Eclipse is asking me to add all the dependent plugins. I have done that.
However, on adding a new plugin, it starts asking for dependencies (e.g., third party libraries from Eclipse's Orbit repo) of that plugin too. All the dependencies of individual plugins are referenced in those plugins.
Why do I have to add all the references again in the RCP plugin. What is the way around or right way?
The xxx.product file must list every plugin that your RCP is going to use as this list determines what is included in the resulting product.
This is a separate list from the individual plugin dependencies.
The Dependencies tab of the .product file editor has an 'Add Required' button which should add everything that is needed (assuming you have already added all your plugins).
You can also use 'features' rather than 'plugins' for the product file which reduces the number of things that need to be included in the dependencies.

Exporting an GEF-Editor as a runnable JAR

As stated in the title: I want to run an Eclipse-Plugin, more specifically a GEF-Editor, without starting an Eclipse instance before.
I've tried to use the export functionality provided in the MANIFEST.MF file:
However, running the generated JAR (call it editor.jar) by executing java -jar editor.jar on the command line fails with the message no main manifest attribute, in plugins editor.jar.
I'm aware of the fact, that this is because my MANIFEST.MF file is missing the following line
Main-Class: <packagename>.<classname>
which defines an entry point for my application. However, I've no idea what exactly I need to do here (in the case of an Eclipse-Plugin), cause I don't have something like a main method. I assume Eclipse is running some magic code it doesn't show to me, when I start my project as an Eclipse Application.
So, what do I need to do?
You could try running a GEF editor as a Java application. See Draw2D examples to understand how it can be done. You could probably re-use your GraphicalViewer and PaletteViewer, which means that mouse based interactions with the diagram and palette will be preserved.
However, your editor class would probably have to be incorporated into an SWT shell. Also, all actions contributed to by your editor into Eclipse toolbars, popup menus etc. would be gone. Outline and Tree view would have to be incorporated into your java app somehow if needed.
Think you'd be better off with an RCP application.
Wrap your GEF editor in a simple RCP. You can create one via the Plug-in wizard, setting "Would you create a rich client application?" to "Yes" in the process. This gives you the option to create a minimal application via the Hello World template in the next step. Once you have this, you can either embed your GEF editor in this plugin, or declare a dependency from the new RCP application to your GEF editor plugin, and start the editor from the Application class' start method.
For an overview of resources about RCP development, cf. Getting started with the Eclipse RCP.
It really doesn't add that much overhead to your editor but gives you the opportunity to work with the platform's workbench and workspace metaphors and create easy-to-deploy-and-use application bundles.
Once you have that in place, you can test your RCP from plugin.xml > Overview > Testing > Launch an Eclipse application. This will not run a whole new instance of the IDE, but just the RCP application itself.
Rather than exporting from the MANIFEST.MF, look into creating a product (you can do it via the wizard: New > Product Configuration), and building it via the Maven Tycho plugin(s) (have a look at the respective - really worthwhile - tutorial from EclipseCon Europe 2012: http://eclipsecon.org/europe2012/sessions/building-eclipse-plugins-and-rcp-applications-tycho.html, this includes a section on creating a product as well). Tycho gives true cross-platform builds, as long as you're not on Windows.
No magic code there :).

Runtime error of NoClassDefFoundError when a eclipse plugin depends on other eclipse plugin

I have an eclipse plugin project com.prosseek.asttest, and I spin off a new plugin project com.prosseek.impactAnalyzer that has one class CallHierarchyGenerator.java. Now asttest project depends on impactAnalyzer project. I had no choice but to make impactAnalyzer project eclipse plugin as it uses JDT library.
After setting up the build path in com.prosseek.asttest, it builds without a problem.
However, when I execute the plugin, I got an error missing CallHierarchyGenerator.java class.
What might be wrong?
If you are running this as an OSGI or Eclipse Application, you need to explicity export packages as available to other plugins as by default they are not. Open your manifest editor in plugin 1. Click on the runtime tab and add the packages as "Exported" then the class loader in blugin 2 will be able to find it.
Also looks like you might be doing the class path configuration wrong. in plugin 2 make sure you add plugin 1 as a dependency in the dependencies tab of the manifest editor. Looks like you are doing a dependency configuration as if it were a regular java application
Based on Duncan's answer, I could fix this issue.
Export packages in impactAnalyzer
Actually I didn't add it manually, but it's already exported, as (I guess) I did it with Quick Assist automatically.
Required Plug-ins
I had to Add com.prosseek.impactAnalyzer in the dependecies.
Run configuration update
I had one more step to do, I had to open run configuration to add required plug-ins.
Export the plugin
When exporting the asttest plugin, I also had to export impactAnalyzer also.

Eclipse RCP: build product able to load all plugins in plugins directory

I need to configure my eclipse product to load all features/plugins in features/plugins directory. Now my product loads just plugins that are listed in metadata, so if I export some plugin directly from eclipse tool as "deployable plugins" it's loaded in my product, but if I put a plugin jar directly in plugins directory It doesn't appear (the same if I work with features)
I simply make new product configurations, put the feature that contains my application plugin and then exporting product I have this problem.
My eclipse version is 3.6.1
I think the problem is in the launcher configuration but I don't know what I have to change
In theory, your exported RCP application should simply pick up any new features and plugins you add later. However, make sure you put the extra stuff in the dropins folder of your RCP, since this is the expected location for manually installed features since the introduction of p2.
If for some reason it still doesn't work, try launching Eclipse with the -clean command line argument.
According to The Eclipse runtime options page, the -clean argument has the following effect:
[...] any cached data used by the OSGi framework and eclipse runtime will be wiped clean. This will clean the caches used to store bundle dependency resolution and eclipse extension registry data. Using this option will force eclipse to reinitialize these caches.
In my experience this can resolve many mysterious cases, where newly added plugins are not loaded by Equinox.

Modifying Existing Eclipse Plugin and Correctly Installing it

I downloaded the source code for the EMF based UML2 Plugin and changed a class in the org.eclipse.uml2.uml.edit project to remove special characters when returning string representations. Now when I export the projects and place the jar files either in the dropins directory or replace my current uml2 plugin jar files in plugins directory, The UML files are no longer recognized, in short my modified plugin does not install correctly (no error is thrown and I can see the files being picked up under Plugins->Target Platform) .
However, When I run the plugin as an eclipse application (from the workspace) I can see the changes I made being reflected in the new instance of eclipse.
What can I do to ensure that the plugin installs correctly?
Is there a documented procedure of how to build the uml2 plugin (or any comparable plugin) after modification?
Select the project and open the context menu. There is an entry PDE near the bottom of the menu. In there, you can find an entry to build the plugin for deployment. This gives you the features and plugins directory with the fixed files. Copy both into your Eclipse install.
Unless the UML2 plugins require some kind of magic build script, exporting the one plugin you changed and overwriting the original in your Eclipse installation should be the easiest solution. One potential problem which comes to mind is conflicting plugin version numbers: make sure you don't have two identical versions of your modified plugin in your Eclipse installation.
When debugging plugins which apparently don't work properly at runtime, I always look at Help > About Eclipse Platform > Configuration Details. This lists all the plugins found by Equinox during startup, along with their status (see the Javadoc of the org.osgi.framework.Bundle interface for explanation).
I faced the exact same problem as you describe here . I dont have any answer to your problem but i am sharing what worked for me .
I created a local update site of the plugin on my system. Create update site for your plug-in article explains very very nicely the steps needed to accomplish this .