I decided to drop my own hosting and moved to WordPress hosting. Since 2007 this blog was hosted at http://urbas.tk but recently it was moved to https://radektech.wordpress.com.
Three problems with starting brand new Eclipse 4 RCP application
Recently I decided to finally give Eclipse 4 RCP a try. I created small application in a few minutes. Everything worked smoothly in Eclipse IDE. Next step was to prepare Maven build. Using Tycho 0.16.0 I was able to build my brand new RCP application using command line. The problems started when I tried to run application built by Maven.
Here are three problems I experienced:
- Application crashing on start-up with an exception like this:
org.eclipse.core.runtime.AssertionFailedException: null argument:applicationXMI argument missing
In order to resolve that I had to add new program argument (Launching tab in Product Configuration Editor)
-clearPersistedState
- Application crashing on start-up with another exception:
!ENTRY org.eclipse.osgi 4 0 2012-11-20 20:43:46.516 !MESSAGE Application error !STACK 1 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
When you run your RCP application from IDE start-up levels for bundles are set appropriately, but this does not happen in product configuration. These three bundles should have Auto-Start set to true and following start levels (Configuration tab in Editor):
- org.eclipse.core.runtime 2
- org.eclipse.equinox.ds 3
- org.eclipse.equinox.event 3
- Application starting up fine but no controls being rendered inside a part. Eclipse remote debug helped me to determine that an part object was instantiated as expectged but a method creating all the controls wasn’t actually called. For some reason annotation @PostConstruct wasn’t respected. In order to resolve this issue I had to replace bundle javax.annotation 1.1.0 with version 1.0.0. Eclipse Juno IDE is shipped with version 1.0.0 so everything worked fine there but Tycho picked up version 1.1.0 from Eclipse p2 repository for Juno.
Generating p2 meta data from command line
Many times when working with Eclipse RCP I had to generate ad-hoc updatesites (usually containing some 3rd party plug-ins). What I usually did to achieve this (with Eclipse IDE):
- create new feature project
- add plug-ins to the feature
- create new updatesite project
- add the feature to the updatesite (pre-p2 style – site.xml)
- export newly created updatesite (letting Eclipse to deal with creating p2 meta data)
Since I needed to automate this process I started researching on p2 capabilities and found out that it can be done from command line using FeatureAndBundlesPublisher application. Sample command line invocation to do it:
%ECLIPSE_EXE% -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:/%P2_TARGET% -artifactRepository file:/%P2_TARGET% -source %P2_SRC% -compress -configs win32.win32.x86 -publishArtifacts
Where:
- ECLIPSE_EXE – points to Eclipse executable;
- P2_TARGET – path to an empty directory where p2 repository should be created;
- P2_SRC – path to the directory with /plugins subdirectory and plug-ins to be published (jar files) inside;
- -compress parameter is optional. It compresses artifacts.xml and content.xml to jar (zip) files.
Running servlets inside Equinox/Eclipse
- Creating plug-in hosting servlet
- Create new plug-in project

- Add plug-in dependencies
- javax.servlet
- org.eclipse.equinox.http.registry
- Add extension: org.eclipse.equinox.http.registry.servlets
- Configure servlet mapping in extension definition
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.equinox.http.registry.servlets"> <servlet alias="/echo" class="servlets.EchoServlet" /> </extension> </plugin>
- Create servlet class
package servlets; package servlets; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class EchoServlet extends HttpServlet { private static final long serialVersionUID = 137926368689939745L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) { String value = request.getParameter("value"); PrintWriter writer; try { writer = response.getWriter(); String outputText = "Echo Servlet inside Equinox/Eclipse says: " + value; System.out.println(outputText); writer.write(outputText); writer.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
- Create new plug-in project
- Running plug-in hosting servlets in Eclipse IDE
- Create new Run Configuration
- Choose OSGi Framework
- Deselect all preselected plug-ins from bundles list
- Select only:
- Newly created plug-in that’s hosting servlets
- org.mortbay.jetty.server
- org.eclipse.equinox.http.jetty
- Use Add Required Bundles option
- Save configuration and Run it
- Using servlet
- By default when running this configuration Jetty will start on port 80
- Open a browser and hit URL for this example http://localhost/echo?value=Hello


Adding menu item, command and handler
Step by step in Eclipse IDE
- Create new Eclipse plug-in: File -> New -> Other -> Plug-in Development -> Plug-in Project
- Add dependency: MANIFEST.MF -> Dependencies tab -> Add -> org.eclipse.ui
- Add extension point org.eclipse.ui.menus: plugin.xml -> Extension -> Add -> org.eclipse.ui.menus
- Right-click -> New -> menuContribution
- Enter locationURI: menu:file
- Right click -> New -> command
- Enter commandId: tk.urbas.eclipse.sample.sampleCommand
- Enter label: Sample Menu Item
- Enter locationURI: menu:file
- Right-click -> New -> menuContribution
- Add extension point org.eclipse.ui.commands: plugin.xml -> Extensions -> Add -> org.eclipse.ui.commands
- Right-click -> New -> command
- Enter id: tk.urbas.eclipse.sample.sampleCommand
- Enter label: Sample Command
- Right-click -> New -> command
- Add extension point org.eclipse.ui.handlers: plugin.xml -> Extensions -> Add -> org.eclipse.ui.handlers
- Right-click -> New -> handler
- Enter commandId: tk.urbas.eclipse.sample.sampleCommand
- Enter class: tk.urbas.eclipse.sample.SampleHandler
- Click class link and create class
- Provide sample implementation of the handler class implementing org.eclipse.core.commands.IHandler or extending org.eclipse.core.commands.AbstractHandler
- Right-click -> New -> handler

Menu, command, handler
MANIFEST.MF
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Sample Handler Bundle-SymbolicName: tk.urbas.eclipse.sample;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Vendor: urbas.tk Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.ui
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:file">
<command
commandId="tk.urbas.eclipse.sample.sampleCommand"
label="Sample Menu Item"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="tk.urbas.eclipse.sample.sampleCommand"
name="Sample Command">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="tk.urbas.eclipse.sample.SampleHandler"
commandId="tk.urbas.eclipse.sample.sampleCommand">
</handler>
</extension>
</plugin>
Handler – sample implementation showing a message
package tk.urbas.eclipse.sample;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
public class SampleHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
MessageDialog.openInformation(Display.getDefault().getActiveShell(),
"Sample Handler", "Sample Handler");
return null;
}
}
JDD09
4th edition of Java Developers’ Day is over. It was the first time I attended this conference. I enjoyed most of the sessions and the organization was pretty good. I will definitely plan to be there next year as well. My favorite JDD09 speakers/sessions:
- Effective Code Review for Agile Java Developers – Wojciech Seliga (I need to try Crucible!)
- Common Anti-patterns and Ways to Avoid Them – Mark Richards (It could be at least twice as long as it was)
- Resource-Oriented Architecture (ROA) and REST – Scott Davis (A lot of evangelism but the show was really good)
Eclipse 3.5 Galileo – my personal Top 5
There are several new and exciting features in Galileo release. Multiple projects, hundreds of contributors, huge audience…
I decided to choose my very personal Top 5 for Galileo release:
- Update. New UI for installing and updating new features in Eclipse really leverages user experience. After introducing p2 in 3.4 a lot of people missed old Update Manager. With more stable and matured p2 in 3.5 version hopefully no one is missing 3.3 style updates any more. One capability I would find useful there is installing particular Installable Units instead just these which are based on Eclipse features. In p2 world all IUs are supposed to be equal.
- Setting the cookies in Browser. I’m really happy to finally see setCookie(value, url) method in SWT Browser class. That’s the part of API that was really missing there to make embedded browser more functional in Eclipse RCP world. Next step would be probably providing SWT support for the Webkit based browsers.
- Target Platforms. Galileo way of defining target platform is another item I find really useful for Eclipse RCP. Finally at least partially runtime for Eclipse RCP application can be independent from the plug-ins set in Eclipse IDE used for development!
- Mylyn. Previous Mylyn version satisfied most of my requirements to work with Bugzilla. But new Mylyn Editor just feels better for me even if it took me a day or two to get used to the context activation button being moved from right to left side of the toolbar.
- OSGi Declarative Services. I’m excited about declarative services in Equinox. I didn’t have opportunity to try it yet but I have high hopes for the near future!
Considering learning new language/technology
I’m considering learning new programming language or technology.
My very basic requirements:
- no for buying new laptop (I’m happy with my ThinkPad)
- no for buying new mobile device just to run something at all (I’m happy with my Nokia)
Any suggestions?
That is why WordPress is so cool
Single click …
Downloading update from http://wordpress.org/wordpress-2.8.zip
Unpacking the core update
Verifying the unpacked files
Installing the latest version
Upgrading database
WordPress upgraded successfully
… and voilà! Upgrade completed!
