December 23, 2012

Configure Subclipse to Use SVNKit

After you have installed and restarted Eclipse you might see this error dialog

And the solution to your problem is to configure Subclipse to use SVNKit. To change your Subversion settings open Window -> Preferences and choose SVNKit.

Getting Started Guide for Eclipse with Maven (m2eclipse) and Subversion (Subclipse) Plugin

In this tutorial I will show you how to get started with Java development with Eclipse and its common plugins.
First, if you haven not yet done it, install Java SDK. Here I will use a linux client, but the same yields for a Windows client environment, except installing program is more comprehensive in Linux.
On a Internet connected Ubuntu 12.10 Quantal client, simply open a terminal and print.

Then you need Maven. Here I will use Maven 3, which is the recommended version for building new Java project. For Ubuntu client simply continue typing in your terminal:

Now you need to install Eclipse. I recommend NOT to use the latest version, since it is remarkably slower then the previous version of Eclipse Indigo (3.7). Simple open the below link in you web browser and download the right version version for your operation system and architecture. Then unzip the compressed file in you programming directory.
Now check that eclipse points to your default java home directory, where source code is also stored.

Now you need to install two plugins, Maven (m2eclipse) and Subversion (Subclipse) plugin. Installing extra plugin in Eclipse is quite simple. Open Window → Install New Software.... Now enter the below URL and follow the Eclipse guide.


November 15, 2012

A Better Maven POM for Wicket Archetypes

If you are new or just wants to try Apache Wicket there is a good Wicket Maven Archetype for that. You can find instruction for that at

But the generated pom.xml leafs room for improvement. A better pom would be

The differences I made are the following.

1. Downgrade the Jetty Maven Plugin to 7.5.0.v20110901

The new jetty plugin are much slower than the old one and you want miss anything important.

2. Add Wicket Datetime Dependency

Wicket provides a good datetime picker and I recommend that you use this.

3. Configure Jetty Maven Plugin for Autodeploy

The jetty plugin can automatically be configure to pick up any changes made within Eclipse and automatically redeploy your application. This is a great way to develop and I recommend it.

You also might want to mock any possible server facade class, which is located in your test directory. To enable that add your web test classes to jetty classpath.

November 13, 2012

Where is Additional Driver in Ubuntu 12.10?

Yesterday I had problems with my wireless network card and then looked after the Additional Driver that existed in previous version of Ubuntu and it has been moved. To get it open Software Updated from Unity.

Click Settings... and the Additional Drivers tab.

Broadcom Wireless Network Card not working after updating Ubuntu 12.10

Yesterday I updated my HP ProBook 6550 with Broadcom 4313 with my fresh installed Ubuntu 12.10 and suddenly my wireless network card stopped working. I google and found the following article But that did not helped, until I also installed

System Development Environment on Ubunut 12.10

With the latest Ubuntu release most of the tool a Java developer needs comes packaged in official release packages.

Open JDK 7

The open JDK 7 is mature and ready for production. This since the latter version of Open JDK 6. The reason for this is that now Oracle really develop the next version of Oracle JDK version is done in the Open JDK version. Previously when Sun owned the Java SDK they merely dumped source code in the Open JDK repository, but Open JDK is really a upstream project.

Maven 3

Subversion 1.7

Please note that there is a big difference between svn 1.6 and 1.7, where 1.6 was the official package version in Ubuntu 12.04.

Subversion Client

If you have previously used RabidSVN, you should consider switching to KDESVN

Best Practice Apache Wicket

There are some guidelines written about the best way how to use Apache Wicket, but I think I might have some more to contribute to all the things that has already been written.

1. And maybe the most important is always use Wicket Models.

First Wicket is a component based framework, which in itself implies you should always use Wicket Models.

Secondly wicket is also a framework that out of the box handles the back button dilemma, which is what should happen when the user press the back button in the web browser? Wicket handles this by versioning every page. Which means that if a user have in entered some data in a HTML form, then submitted and thereafter presses back button, Wicket will then out of the box present the values the way it was before pressing submit AND keeping you server Model in synch. You can get a good feeling of the above by playing around with the form example at

To achieve this Wicket uses the HTTP Session to store the previously pages states. To not now blow the RAM space on the server, you should almost always use the LoadableDetachableModel.

Be sure you have completely have understood the antipatterns at

The second and maybe finally most important Model is the CompoundPropertyModel. And remember that you can wrap Model. Example of that is:

2. To keep wicket code more readable, avoid using anonymous inner classes.

Wicket as well as Swing code can blow up in your face when it comes to anonymous inner classes. Instead write separate classes in the same WebPage class, like the above example. Which result in in a much more cleaner code.

3. Try to only use the PageParameters constructor

Example of that you can see in the above PersonPage example. The reason for that is now you page can always be bookmarkable. Which the default constructor also can be, but it is more generic to directly use the PageParameters constructor, in case you later need to use a page parameters.


4. Do not try to reinvent the wheel when it comes to graphical components.

Wicket comes with a rich set of ready to use graphical components. Be sure to import them in your pom file.

If you need more have a look at, which have a nice WYSIWYG editor and a spinner.
Also since Wicket 6 is jQuery the backend library for Ajax. Look for example at the jQuery modal window at


5. Use Wicket XHTML namespace



6. Be sure you have configured Maven Jetty Plugin to restart whenever you have made code changes

7. And remember you can always debug your Wicket code with a JUnit.

Wicket has a great support for module testing support. But these test cases can also be used for debugging. When generating a Wicket project with the archetype you get a single JUnit test case with that you can start Jetty and then simply add breakpoints and you can debug your code.

September 19, 2012

How to add Bookmark/Shortcut to Left Sidebar of Nautilus Manager in Ubuntu 12.04

1. First open the folder you want to bookmark.

2. Then press Ctrl+D. Now will a new bookmark be created in the upper left corner of nautilus manager.

September 2, 2012

Configure DatabaseServerLoginModule with Hashed Password on JBoss 7 AS

In this blog I will show you how to install in JBoss 7 AS and store the password in hashed format. The advantage of storing the password in hashed form is that a DB admin can not read the user's password in clear text. Which add a great security value.

Before we begin our tour we need to first install a database driver. In my previous blog I showed you how to install MySQL driver, please see And in this blog I will continue to use MySQL for my data source. We will also use JBoss in standalone mode, since we are dealing with a single node installation. Remember to look at the new JBoss module capabilities if you are facing a multi node installation and you want to share the same configurations.

After you have installed your data source you can check your configuration by starting JBoss and you should receive something like in your JBoss server log.

Bound data source [java:jboss/datasources/MySQLDS]

Now continue by creating database schema and tables: Now we continue with add a new security domain, i.e. actually configure our database login module Now we need a web application. I did not bother to build a maven application for that so I simply created a new folders manually A simple Index.jsp page And the standard web application deployment descriptor: And the corresponding JBoss application deployment descriptor: Before we can fire up JBoss we need to tell the JBoss container to deploy the exploded web app. Now we can start JBoss and look for the deployment info log,

Deployed "msc-secure-webapp.war"

Now when we try to access the web application at http://localhost:8080/msc-secure-webapp we are meet by a username and password login window. Since we do not have any user in our database we will not be able to login yet.

Lets create some user. But how do we do that when the password are suppose to be stored in a hased format? Either you can write a small Java program to get the hashed password a easier way is to use openssl. To create a hashed password for admin simple enter And with that hashed password we can create a new user with the followin sql insert. Now you can open your web application http://localhost:8080/msc-secure-webapp/ and log in with username "admin" and password "admin".

August 16, 2012

Eclipse Keyboard Shortcut Does not Work on Ubuntu 12.04

When I installed Eclipse on Ubuntu 12.04 (or rather just unzipped the eclipse binary in my home folder and started the eclipse executable) some common Eclipse keyboard shortcut was not working, like Organize Import Ctrl+Shift+O or Inspect when debugging Ctrl+Shift+I. And the problem was that they were conflicting with the OS Ubuntu keyboard shortcut. To remove/edit the Ubuntu keyboard shortcut simply open Ubuntu Keyboard and walk through conflicting Eclipse keyboard short and either remove the Ubuntu keyboard shortcut or reassign them to other keyboard shortcut.

In the example below I simple removed the Ubuntu keyboard shortcut for Zoom in and Zoom out, since I don't need them.

August 15, 2012

How to Install Maven 3 on Ubuntu

So far there Maven 3 package is not yet available in the general Ubuntu repository, so you will have to do it manually. There are several way to do that, but I think the easiest way is to do it manually.

In short the installation follow:

August 13, 2012

How to install MySQL DataSource on JBoss EAP 6 and AS 7.

The interior of the JBoss EAP 6 and the community version JBoss AS 7, which EAP version is based on, has changed a lot in the latest version. In this blog I will walk you through how to install a MySQL DataSource, and by doing that I will touch two important differences with the new version of JBoss.
  • The changed classloading to a more OSGI like architecture.
  • The simplification of have only one configuration file.
First we will create a new module. A module in this sense is a package of classes that will be available to all our application through your JBoss node. This is a big differences compared with older JBoss version where all deployed archive where directly available to other deployed application when deployed in the deployment root folder.

You find module in $JBOSS_HOME/modules folder. To create a new module you need to do three things:
  1. Create a folder hierarchy for files.
  2. Copy module jar files.
  3. Create module configuration file – module.xml.
Now edit the module.xml file: Now you are ready to use configure your DataSource. Here I will use the JBoss Standalone and not the Domain configuration. In short the main differences between Module and Standalone JBoss configuration is if you want to reuse your configuration through several JBoss instance you shoud use the Domain configuration approach. In this blog I will use the Standalone configuration, but the differences of doing the other way around is not big.

The configuration of the JBoss can be done in several way: 1. CLI 2. Web interface 3. or manually through editing xml file. Which way you choose is up to you, here I will show the result.


August 1, 2012

Search JAR Files after Specific Class

Ones in a while I need to search in a lot of jar files after a specific class class and that is what this command:

July 27, 2012

Java EE 6 Annotations - JSR 250: Common Annotations

In my previous blog I was writing about the CDI annotation in EE 6, in this blog I will write about the The Common Annotations, namely:

Resource Injection:
Managed Bean:

javax.annotation.Resource and javax.annotation.Resources

The @Resource and @Resources are shortcut for doing jndi lookup, e.g. new new InitialContext().lookup(name).

javax.annotation.PostConstruct and javax.annotation.PreDestroy

The @PostConstruct and @PreDestroy are neat annotation to do initialization and clean up in a standardized way. I would recommend to use these annotation even if you are not deploying to an enterprise environment. The above annotation can be used on any bean, such EJB, MDB, Managed Bean, but if you annotate a POJO, you need to fetch that POJO with @Inject to make the PostConstruct and PreDestroy be called.


This annotation should NOT be mixed up with javax.faces.bean.ManagedBean or JMX Managed Bean. It is a lightweight component that enables resource injection, lifecycle callbacks and interceptors. I my self is not totally sure where this component fits in, but it's there.

Java EE 6 Annotations - JSR 299: Contexts and Dependency Injection - Part 2

In my previous blog I wrote about the new CDI annotation in EE 6 and now you would probably want to test them. You can of course package your archive and deploy it to your a EE container, but that is clumsy, tedious and harder to debug. What you rather want to is to write a JUnit test cases and with that be able to debug/run it from your IDE. There are several way to do that, but two major solution are:

In this blog I will show how to do that with JBoss Arquillian, but Apache OpenEJB is also a good solution.

There is a rather good getting started guide at, which I encourage you to read and here I will give you a shorthand version, but also give some more clarification about the Arquillian Maven dependency.

First add JBoss Maven User repository, which is described here,

Then create an empty maven project. Modify your pom.xml accordingly

There are two importing thing to stress here. First we need to understand one imported design goal with Arquillian and that is it was meant to be conainer neutral, i.e. the Arquillian test should not be affected if you decided to run your EE test on a different EE Container. And this design goal is reflected in the  Arquillian Maven dependency module.

So with that in mind, the first dependency arquillian-weld-ee-embedded-1.1 is only an adapter and does not contain any real CDI implementation code, which is in this case the Weld implementation code.

The second imported thing to understand is that Weld does not support EJB or any other similar EE modules, it only supports CDI.

If you want more container support look at the following pom,

Java EE 6 Annotations - JSR 299: Contexts and Dependency Injection - Part 1


One of the maybe biggest new feature in EE 6 is the Dependency Injection, DI, support. Many of you are already familiar with the this concept after been using Spring, Guice or other DI framework. But now these feature are standardized in the EE 6 specification via the following Annotations:


Core DI package []
"Annotations and interfaces relating to scopes and contexts." []
  • javax.enterprise.context.ApplicationScoped
  • javax.enterprise.context.SessionScoped
  • javax.enterprise.context.ConversationScoped
  • javax.enterprise.context.RequestScoped
  • javax.enterprise.context.Dependent
"Annotations relating to bean and stereotype definition, built-in qualifiers, and interfaces and classes relating to programmatic lookup." []


The @Named annotation is used for alternative lookup id. Example And the JSF/JSP page:


The @Qualifier is used to qualify injection if there are multiple candidate in the classpath. Example a bean @Inject an interface but there are several implementation of that interface in the classpath.


You might think the above scooping Annotation are only used with JSF, but in fact these Annotation can be used on any Bean, for example try to annotate a POJO with @ApplicationScope and then grab it with the @Inject annotation in a Bean.


The @Alternative annotation is used for annotating a class to be ignored for @Inject lookup, and to enable must it be declared in META-INF/beans.xml. Example: META-INF/beans.xml And now can @Alternative be used with @Inject


The @New annotation creates a new inject instance of Object, good example is shown in EE API,


“The @Any qualifier allows an injection point to refer to all beans or all events of a certain bean type.” []


The @Produces annotation can be seen as a factory. Good example can be seen here


And the @Disposes is the cleanup method for factory @Produces.

Now I presume that you are eager to get started testing these and annotation and that I will describe in my next blog

June 29, 2012

JUDCon and JBoss 2012 Boston: OSGi is coming back

I don't know how many of you are using OSGi, but my feeling was it was a hot topic a couple a year ago and then everything cooled down. But now it looks that the Java EE container vendor are picking it up again. The following table below show the support of OSGi in the biggest EE containers:
App Server Deploy Bundle WAB Support* EJB/JPA
Glassfish Yes Yes Prototype
Webspere Yes Yes Prototype
WebLogic No No No
JBoss AS Yes Yes No
*)WAB, Web Archieve Bundle

This is all interesting you might think, but what impact will that have on the Java EE architecture? I would say a rather a lot. Lets start with the deployment. All Java EE deployable are monolithic, think of web and ear. They all package everything in on single file. How does that go with the OSGi moduling thinking? Not at all. The OSGi concept is programming modules and make them interchangeable, deployable as separate module and with own versions lifecycle. So this has to change if one want to bring the OSGi thinking to the Java EE arena.

If you want to play with OSGi I would recommend Eclipse and install the bnd tool (

And if you want to read more about OSGI OSGi in Action by Manning is a great book.

And at more architecture level I would recommend Java Application Architecture

JUDCon and JBoss 2012 Boston: Red Hat released the JBoss EAP 6 at june 21 2012

Red Hat keeps the pattern of changing the JBoss server drastically with every major release version and that is the case with JBoss EAP 6 as well.

One of the biggest differences are:
  • Is starting to aim at a more OSGi oriented architecture, the full OSGi support is not there yet, but will be fully supported in JBoss EAP 6.1
  • The configuration has changed dramatically, basically they have moved all configuration to one file instead of having them sprayed out the entire JBoss file directories. And then start using more default which leads to a great reduction of the configuration file.
  • The startup and running lifecyle has changed and comes down to two ways domain and standalone, which is quite similar to Oracle BEA, if you are familiar with that.
I will hopefully blog more about the JBoss EAP 6 in future.

But there were also more releases announced at the same day and maybe from a developer point of view, the most interesting was the the improved JBoss best practice documentation sites:

The JBoss Way

JBoss Developer Framework

Another big and important announcement is that the project Wolf has finally delivered. The project Wolf is about providing a centralized maven repository for the JBoss EAP development. And this repository is also shipped with JBoss EAP.

And all the presentation will be made available at

June 28, 2012

Improve your performance on Ubuntu 12.04 with Jupiter

I had some performance problems with Ubuntu 12.04 when my battery started to run out. To help this I installed Jupiter and change to Maximum Performance.
For details see

And if you like to change the default Icon simply replace the /usr/share/pixmaps/bolt1-4.png files. For details see

June 1, 2012

How to install install and configure SSL on Tomcat 7

In my previous blog I described how to install and configure SSL on Jboss 5.1 ( and in this blog I will how to do the same but for Tomcat 7. And you will see it is very similar. And the reason for that is that JBoss is actually using Tomcat as web container. So to configure SSL on Tomcat follow the same step as in my previous blog to create server certificate and then open server.xml add the following configuration for the https Connector.

$CATALINA_HOME/conf/server.xml: Then reuse the previous test application and open your browser. Here you will get a warning about a self-signed certificate. Accept it and you will see your application.

Performance Tuning Web Pages

Yesterday I had a problem with a web based system that was not very responsive. After some effort I later found out it was certain javascript that was slow and these javascript were hosted by another company on another server. After some researching I found out that if I moved the script from the header html tag to the end of the file before the closing body html tag, the page was rendering directly in the client browser, and the slow javascript was afterwards loaded in the background. In this way the slow javascript was not stopping the user from interacting with the web system, but of course will not the javascript be run until it is downloaded.

Before: After:

May 31, 2012

How to install install and configure SSL on JBoss 5.1

The reason for installing SSL (Secure Socket Layer) is to protected the data received and sent to be read in clear text and instead received and sent encrypted.

The first you need is a Server Certificate. You can get a valid Certificate from Certification Authority (CA) like Thwate, Verisign and many more. But here I will use a self-signed certificate but the process is quite similar for the ones from a Certification Authority (CA). Remember that the first and last name should be either your domain address or machine name.

And to view your self-signed certificate: Now you need configure your HTTPS Connector.

$JBOSS_HOME/server/$JBOSS_CONF/deploy/jbossweb.sar/server.xml: There are several more configuration for the Connector which you can read more about here for JBoss 5.1:

And the latest documentation is found here:

The last thing we need is a test application I will leave that as a practice, but I will show one interesting part and that is the web.xml

Now open you web browser and test your application. To do the same for Tomcat is quite similiar, read more about it in my next blog -

May 19, 2012

How to find out which version of Ubuntu

From a Terminal (Applications → Accessories → Terminal)

And to find out if you are running a 32 or 64-bit OS.

For 64-bit you will see: x86_64
and for 32-bit: i686

Top Things After Installing Ubuntu 12.04 Practical Precise

1. First update your system.

2. Enable Restricted drivers available

Open Additional Drivers and select Recommended driver.

3. Remove overlay bar:

4. Add Medibuntu Repository

5. Install Common Codecs

6. To play encrypted DVDs

7. Install Non Open Source Programs

8. Install Video Player

9. Video Editor

There are several easy to use video editors out there: Here are two:
  • Avidemux
  • Openshot
You install both from Ubuntu Software Center.

10. Torrents client - qBittorrent

A Simple to use Bittorrent client is qBittorrent. You install it easily from Ubuntu Software Center.

11. Manage Unity - MyUnity

If you are not happy with the dock you can easily change it's appearance with MyUnity. You install from Ubuntu Software Center.

12. Oracle Java 6 

If think the best way to install Oracle Java SDK is to do it manually. An easy to use guide is here

13. Set $JAVA_HOME

I have previously describe how to set the Java environment home variable here:

14.Keyboard Shortcut 

15. New Launcher (Shortcut) in Dock

I have previously described it here:

16. LibreOffice

If you need to install more language for spelling checking, first download the wanted

How to install:


Check installation under Tools -> Options -> Language Settings -> Writing Aids and Edit Module.