Tuesday, February 03, 2009

When the runtime Application uses the wrong plugins...

Today I run into a problem that can cause a lot of frustration: a runtime eclipse launch that runs with he wrong plugins. The frustration comes form the fact that your application behaves strangely and it is hard to guess that this is caused by loading some worng plugins. Those plugins might even be closed or deleted from your workspace!

Here is what happens: PDE (eclipse 3.4) does some hidden magic when you run an eclipse application (lets call the launch configuration foo): it creates a directory in .metadata/.plugins/org.eclipse.pde.core/foo. This directory is used with the -configuration flag when running the application to store the runtime configuration of your application. But, there can be cases when this directory is not updated correctly, like when you switch between "launch with all enabled and workspace plug-ins" and "plug-ins selected below". It can happen that the runtime application still uses all plugins although you have selected to run with some specific plugins. I have not tested the exact conditions when this happens, but it happened several times to me in the last months.

Unfortunately the "Clear workspace" flag does not help, because it clears the workspace but not the configuration area! It took me several hours to figure that out....

As Chris points out in the first comment, here is the solution: On the "Configuration" tab of the launch configuration check the option "Clear configuration area before launching".

Chris also recommends to use -clean -consoleLog -debug -console as arguments for plugin development launch configurations. In this case, the -clean option takes care of cleaning the configuration area.

Tip: you can set -clean -consoleLog -debug -console as default in Preferences->Plug-In Development->Target Platform->Launching Arguments->Program Arguments

I hope this tip saves someone some wasted time...

.

6 comments:

  1. In the Configuration tab of the Eclipse application launch configuration... there's an option to always clear the configuration area on launch. That will prevent problems like you describe in the post.

    It would be interesting to see your problem in a series of reproducible steps. It could be that there is information being cached that shouldn't be.

    ReplyDelete
  2. I usually just add the "-clean" option to solve this problem. Speaking of which, I recommend running with "-clean -consolelog -debug -console" when developing Eclipse Plug-ins.

    ReplyDelete
  3. Thanks Chris!

    I fixed the solution. My original solution was manually delete the configuration directory. But using the Configuration tab is way better. I did not look at the Configuration tab, maybe because it sounds like configuration in "launch configuration" and not like the -configuration flag....

    ReplyDelete
  4. Michael,

    I also always use
    -clean -consolelog -debug -console
    as chris recommends

    ...if you're using declarative services then its also a good idea to use
    -Dequinox.ds.debug=true
    as vm args - this gives great informations

    ekke

    ReplyDelete
  5. I have also reconigzed this behaviour several times when launching my plug-in projects.
    For me this issue only came up when launching as an Eclipse application, not as an OSGi framework.

    First I thought Spring DM makes some troubles... and that this problem is not related to PDE.

    Thank you for the tip and this blog post!!!

    ReplyDelete
  6. Wouldn't this actually be this right time to open a bug?

    ReplyDelete