Using JBoss EJB 3 with Eclipse RCP [Part 5]

Some code to test

To get something working we need to insert some code in our RCP. We will insert it directly in the All output will be echo to the console so that there is no need for a GUI:

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;


* This class controls all aspects of the application’s execution
public class Application implements IPlatformRunnable {

/* (non-Javadoc)
* @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
public Object run(Object args) throws Exception {
// EJB-Test
Properties properties = new Properties();

Context context;
try {
context = new InitialContext(properties);
MyTestStatelessSessionRemote sess =
System.out.println( sess.sayHello() );
} catch (Exception e) {
// Normal RCP-App Code
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IPlatformRunnable.EXIT_RESTART;
return IPlatformRunnable.EXIT_OK;
} finally {

Now click on „Lauch an Eclipse application“ in the „Overview“-tab to lauch the RCP. If anything is OK you should see a RCP window and an output similar to this one:

Erfolgreicher Test der RCP

Hopefully this small tutorial is a little helpful.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.