Thursday, February 22, 2007

Your first problems with RCP

Now that we had a good start with RCP, we face a couple of problems upgrading our application. First of all, if you are a curious person (and this is a good thing), you might be facing a couple of problems while trying to run your application from outside of Eclipse.

Problem number 1:
You can run your application from within Eclipse but when you try it outside of Eclipse you get a: "No class definition found ...".
If you are having this problem and the class that can't be found is one of your own, you probably made the wrong move! Check on your MANIFEST.MF file if you have a line: "Bundle-ClassPath:".
If you don't, you have gone even further that I though. Add it quickly!
If you have it, check that the path '.' is there. You MUST have '.' as a class path for your application or else none of your classes will be found.

Okay! That was easy to solve now that you found the solution.
You move along and you get challenged again:

You probably created your first RCP application with a product that was based on plug ins, right? Now it's time to move it to feature based architecture. Great! That will enable your application to benefit from the update features.
Go ahead! Change your product file to be feature based. Once you done that, all works perfectly within Eclipse but, again, when you run it outside, it does not works.

Problem number 2:
You can run your application from within Eclipse but when you try it outside of Eclipse you get a: "No application id found ...".

Okay! First thing to do, check the plug in folder from your application. It should contain all plug ins that are necessary to run you application. If one plug in is missing, you get the "No application id found ..." message.
If this does not help you, try opening the file "$YOUR_APP_HOME/workspace/.metadata/.log" with the Error log view in Eclipse. Take a look at the most recent entries. You should see the "No application id found ..." message and some warnings surrounding it.
Take a good look over the warnings looking for one of them that says something about "Bundles missing". It should be extensible. Extend it twice, you'll get a list of missing bundles. Those are the plug ins that the RCP is trying to load and is not finding. Search for errors within those plug ins or if they are available. Once they do, it should restart working once more.

Wonderful! So now you are feature based and your application works perfectly well inside and outside of Eclipse. Time to create an extension point for your application. Eclipse really helps for that. It creates all the necessary files for you and you can focus on whatever you want.

Problem number 3:
You want to define your extension point and you would like it to have children. Like in:

<extension-point id="myapp.myext">
<myext id="ext3">
<status name="fileSystem" />
<status name="swap" />

First of all, when creating your extension point, you'll find out that PDE 3.2 won't let you create a new definition within the extension point element. Don't worry! That's normal. It just doesn't create the xml tree at definition it understands when you use it. Second thing, just like the extension point, you can't create a new definition within your extension-point. Again, same procedure: ignore it and create it after your extension point definition but use it inside and all will go fine.

Now you have your extension points created. Time to create a new project that will extend this point. Go ahead! It's a good idea. So you start and once you done the whole thing you get a warning: "Illegal child element ..." at your "plugin.xml".
Well, my tip: Ignore it! It's a know bug from PDE 3.2 that is already fixed at the repository.

Well, those must be the first problems you'll face with RCP and probably the once you'll loose more time. After this, you understand the errors a bit faster and starts not getting stucked for stupid reasons like I did. :)

If you have other problems with or without solution, please post them and I'll do my best to help or to spread the solution a bit more.

Enjoy yourselves!

No comments: