Tag Archives: eclipse

Using Vaadin Eclipse Plugin under Win7 x64

  1. Download and extract Eclipse x32
  2. Download and extract jboss 7.1
  3. Download and install Java JDK x32
  4. Open eclipse.ini and set path to jvm.dll

    C:/Program Files (x86)/Java/jdk1.7.0_21/jre/bin/server/jvm.dll

  5. Download and install xulrunner from sourceforge
  6. Start Eclipse
  7. Go to help menu -> install new software
  8. Enter “ http://vaadin.com/eclipse” in “work with” field and hit enter
  9. Click checkbox beside vaadin
  10. Click next button to start installation
  11. Restart eclipse
  12. Open server view
  13. Right click and new => server
  14. click on “Download Additional server adapters”
  15. Choose jboss as and install
  16. Restart eclipse
  17. Open server view
  18. Right click and new => server
  19. Choose jboss as 7.1
  20. Hit next
  21. Choose extracted jboss dir from step 2 as home directory
  22. hit finish
  23. In the project explorer hit right mouse menu and choose new project
  24. Choose vaadin 7 project
  25. Enter Project Name and hit finish
  26. Open right mouse menu “add and remove” on the jboss inside server view
  27. add new project with add button and hit finish
  28. start server
  29. right mouse click on the project and choose “run as” => “run on server”
  30. Choose jboss and hit finish
  31. browser will shown with your first vaadin app
  32. hit “click me” button to see if all works

Visual Designer is available if you create a “Vaadin composite” in your project.
Make sure the new file is open in the “vaadin editor”. Switch to the design tab.

Running headless webdriver based selenium junit tests inside jenkins under ubuntu linux

My test setup is for a little wicket 1.5.x based web application with ui tests running during integration-test phase of maven 3.x. The problem here is that my ubuntu 12.01 server has only a console and no gnome or kde running like a desktop linux. Inside eclipse is a test, which starts a browser like firefox to run automated clicks, no problem. I decided to use the webdriver based selenium tests which can use several driver for the different browser. Each driver supports a different browser like chrome, internet explorer or firefox. My tests starts a firefox with explicit locale setting. The wicket application is i18n localized for english an german speaking customer. On the server is a jenkins ci installed with subversion polling to run automated tests during maven build. You can run the scenario with no problems as well under hudson as ci. The solution use xvfb a virtual xwindow system for firefox as desktop. It will automatically started and stopped by jenkins during a job build.

Software Installation on the server

Installation of xvfb

apt-get install xvfb gtk2-engines-pixbuf

Installation of fonts

apt-get install xfonts-base xfonts-75dpi xfonts-100dpi
apt-get install xfonts-scalable xfonts-cyrillic

Installation of tools for testing xvfb

apt-get install x11-apps imagemagick

Testing server installation

1. Console run server

Xvfb -ac :99 -screen 0 1280x1024x16

2. console start firefox

export DISPLAY=:99
firefox http://ralf.schaeftlein.com

3. console make a screenshot

xwd -root -display :99 | convert xwd:- capture.png

And see a result like this when you retrieve the file capture.png via ssh






Jenkins Configuration

Init.d Script for xvfb

Save content as file under /etc/inid.d/xvfb

XVFBARGS="$DISPLAY -ac -screen 0 1280x1024x16"
case "$1" in
    echo -n "Starting virtual X frame buffer: Xvfb"
    /sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
    echo "."
    echo -n "Stopping virtual X frame buffer: Xvfb"
    /sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE
    echo "."
    $0 stop
    $0 start
  echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
  exit 1
exit 0

Set rights for jenkins running user on the script

chown jenkins:root /etc/init.d/xvfb
chmod ug+rwx /etc/init.d/xvfb

Add display environment variable to jenkins init.d script

export DISPLAY=:99

Create a new jenkins job

Create a new jenkins job for your web project stored in subversion

 Add to pre and post build step a shell script to start and stop xvfb









Configure maven pom of the web project

Define special tests in surefire to run as integration tests and jetty as integration application server



Add dependency to selenium maven artifacts


Record ui steps and write a selenium junit test

Install the selenium ide as firefox plugin

Start firefox and install the xpi file as new plugin. Restart firefox afterwards.

Record ui steps

  1. Open the menu, choose web developer and their selenium ide.
  2. Start inside eclipse the tomcat with your web application
  3. Open in firefox the web application
  4. Click  inside selenium ide on the red record button for start recording
  5. Click through your web application
  6. Click again on the red record button for stop recording
  7. Choose from menu “Export as testcase” and their “Junit4 (Webdriver backed)”
  8. Save file as test.java

Create an new selenium junit test file

  1. Copy the test.java into your eclipse project into the src/test/java folder
  2. Adopt the class definition and setup method like this
public class SeleniumTest {

	private Log log = LogFactory.getLog(getClass());

	protected Selenium selenium;

	public void setUp() throws Exception {
		FirefoxProfile profile = new FirefoxProfile();
		// enable german language locale
		profile.setPreference("intl.accept_languages", "de-de,de");
		WebDriver driver = new FirefoxDriver(profile);
		String baseUrl = "http://localhost:9999/"; // port jetty surefire integration test
		selenium = new WebDriverBackedSelenium(driver, baseUrl);

– insert java code –

  1. Check into subversion and control jenkins job console.

Control Hudson or Jenkins from Eclipse Indigo 3.7

For the latest eclipse release 3.7 called indigo is a plugin available to watch and control your build server based on hudson or jenkins. It is part of mylyn 3.5 as a view called “Builds”. See here for more information about the new features of mylyn 3.5. Their is as well a commercial plugin suite called tasktop available.

Howto install:

  1. Go to help -> install new software
  2. Click on “Available software sites”
  3. Click on add with name “mylyn” and url “http://download.eclipse.org/mylyn/releases/latest”
  4. Click ok to go back to site list
  5. Click ok to go back to available software
  6. Choose under “Work with” mylyn
  7. Choose under “Mylyn integrations” the point “Mylyn Builds Connector: Hudson/Jenkins (Incubation)”
  8. Choose under “Mylyn SDKs and Frameworks” the point  “Mylyn Builds (Incubation)”
  9. Click on next
  10. Go through install process and restart eclipse
  11. Choose from menu “Window” -> “show view”
  12. Choose “Mylyn” -> “Builds”
With the blue server icon on the left side of the title bar you can add a new build server. Choose “Hudson” inside the wizard and click next. Enter the url of your jenkins server and enter a label. Click on refresh at the right side under build plans. Choose your favorite builds and click on finish. After that you should have a view similar to the one above. You can start a new build and get updates as notification during the build process.

ide for testing JDK 7 features (Milestone 5: Build b76)

Sun has published milestone 5 (b76) of the upcoming Java JDK 7. JDK 7 release is currently scheduled for September 2010. My standard IDE is eclipse but the current production version 3.5 SR 1 support only Java up to JDK 6. I tried the new eclipse e4 1.0 milestone 2 (status: technical preview) which has JDK support up to JDK 7. You can define a JDK 7 as new JRE and create a new Java project with that JRE and compiler compliance level JDK 1.7. According to Joseph Darcy from SUN is a developer build of Netbeans available with support for JDK 7. I tested with code from CertPal which includes several features of JDK 7. Eclipse e4 still complain about compiler errors but the developer build of netbeans can compile and run the sample code. Check in netbeans under tools -> Java platform the availability of JDK 7 and create a new java project. Set in the java project under properties the source/binary format to jdk 1.7 (sources tab) and choose as java platform JDK 1.7 (libraries tab). On OpenJDK is a overview of the current implemented features of JDK 7 in the M5 version. Mark Reinhold from sun blogs as well about the new features. A more complete list of features which was formerly planned shows Alex Miller in his blog.

GWT with Cypal Studio

GWT 1.5 (official version is 1.5.2) is now finally released and not longer a release candidate. GWT is very nice as AJAX toolkit for a java programmer. You code your application in pure Java and all the JavaScript stuff is done behind the scenes. Important is to understand the build process. The Java Source Code is translated by the GWT Compiler to JavaScript Code. This GWT Compiler understands Java 1.5 with limited API. Eclipse has it’s own built-in Java compiler corresponding to the compiler level of the Java Project. Usage of unsupported Java functions will only be shown by the GWT compiler. Eclipse can only limit the access by setting access rules on the used JRE. In the project preferences under Java Build Path -> Libraries is the JRE. Under this Tree element is the access rules item. In the edit dialog can e.g. the usage limited to java.lang.* by setting “java/lang/*” as accessible. All other classes will not be available and cause compile errors in eclipse.

GWT ships with command line tools to create a new eclipse project including batch files to run the GWT compiler and launch files to start the hosted mode of GWT. Hosted mode starts a embedded tomcat and special GWT browser. The refresh button of this browser recompile the Java Code to JavaScript. Changes in the Java Code will directly shown in the browser after refresh. No restart is required.

GWT has two main concepts for a GWT application. The module defines the main class for a application and the AsyncCallbacks the service layer for accessing server side logic. The module name must be defined for the applicationCreator gwt command line tool as a java package name like com.mypackage.myapp.Main. Inside the source folder of the created eclipse project is the xml file with the gwt project definition and a Java class extending EntryPoint. The EntryPoint onModuleLoad method creates the UI of our GWT module. In the GWT docs online you will find a nice gallery with available ui elements called widgets. Remember that all code inside this method will be translated into JavaScript code.

Accessing business logic requires to define a interface extending RemoteService and a @RemoteServiceRelativePath annotation containing the name of the Service. This service must be implemented by class extending RemoteServiceServlet and implementing your interface. Additionally is a interface needed called <yourInterfaceName>Asyn, which contains the same signatures with a added AsyncCallback callback parameter e.g.

void sayHello(String text, AsyncCallback<String> callback);
final MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class); service.sayHello(textbox.getText(), new AsyncCallback<String>() { public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } public void onSuccess(String result) { Window.alert(result); } }); } });

So many steps has to be made by hand to code a GWT app in this way.

Cypal Studio is a open source eclipse plugin to extend web tools platform of eclipse with GWT. Just extract the install zip file to the plugins subfolder of eclipse 3.3. With Eclipse 3.4 (aka Ganymede) you have to use the dropins/<pluginname>/plugins folder. Cypal integrates as a facet for dynamic web projects. Best environment is a JRe 1.5, GWT 1.5 and a Tomcat 5.5 with this JRE as run time. Call the New Project wizard of Eclipse and choose Dynamic web project. Choose the Tomcat 5.5 as target run time, set web modules version to 2.4 and choose “Cypal Studio for GWT” as configuration. Change either the workspace or project JRE to 1.5. If not done before you must now define the GWT home folder. Give here the path to the extracted GWT 1.5.2 archive. Select under File->New->Other..->Cypal Studio->GWT Module. Give the Module a Java Package name and and a name. The EntryPoint class, the html and the gwt xml file will be created. Under Run->Run configurations you will find “GWT hosted mode application”. Click on the new button, select the Project and click on the run button. The application will be compiled by GWT and the internal browser of GWT started with your Module. Remote Services can be created with File->New->Other..->Cypal Studio->GWT Remote Service. Enter here a name and a uri. Advised is to use the same value for Name and service URI e.g. MyService. This creates a public interface, a async interface, a implementation and change your gwt xml file to include this service as a servlet. Remember to use gwt serializable objects as parameters and return value for your service methods.