17 November 2010

Improvement of Java Will Continue

There are for new JSRs announced on jcp.org

It seams that Java will be continued by Oracle.

12 Oktober 2010

Spring to Java EE

I found a nice article from Lincoln Baxter III:
Link to the article

It's about moving from Spring to Java EE and the differences between them.

06 Oktober 2010

IEEE 1028 Standard for Software Reviews

In these days quality assuarance in software development projects is more important then ever.
Reviews are a good thing beside tests to check if the software under development meets the definied architecture and standards.
IEEE has a standard for reviews. It's called IEEE 1028 (2008) standard for software reviews.

The IEEE 1028 defines five types of reviews:
- Management reviews
- Technical reviews
- Inspections
- Walk-throughs
- Audits

The standard describes the purpose of these five types and defines how to use these review technics. It's really worth reading.

I've found a copy of IEEE 1028 (1997) for free: http://membres.multimania.fr/benoitouellet/Peer_rev.pdf

If you would like to have the newest version you can buy it form IEEE here: http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4601584

04 August 2010

Integrating SeleniumHQ and Maven2

After some days with SeleniumHQ and Maven2 I want to share the finally working configuration. Maybe this could help someone doing the same.

Add Maven Dependencies

Run Configuration

I used the maven-failsafe-plugin to run the SeleniumHQ regression tests in the integration-test phase. The Selenium RC is started with the plugin on port 1234. If you run the tests on a Linux build server without x-server you can find information on the plugin page.

The maven-failsafe-plugin runs any tests with the pattern *IT.java (Surefire uses *Test.java).



To run the regression tests against several browsers and Selenium RC servers I added some system properties:

They can be used in the JUnit Selenium tests like that:

public static void startUp() {
String server = System.getProperty("selenium.server", "localhost");
int port = Integer.parseInt(System.getProperty("selenium.port", "1234"));
String browser = System.getProperty("selenium.browser", "*iexploreproxy");
String url = System.getProperty("selenium.url", "http://www.xyz.com:8080/");
selenium = new DefaultSelenium(server, port, browser, url);

These properties will be set in be default as you can see above or via profiles in the POM:


Simply run the build i.e. mvn install -P localhost to activate the profile.

Skipping Integration Tests

If you need to skip the integration tests you can do this by adding -DskipITs=true. I.e
mvn -DskipITs=true <goal>

15 Juli 2010

Lambda Expressions in Java

As you may know I'm not a big fan of adding closures to the next Java release. Or in other words: don't put stuff to the Java programming language that is not really necessary. In my opinion there are a lot of other missing features but this will come in another blog entry.

A few days ago Brian Goetz wrote about the state of lambda in Java and I think it's worth to check it out - even for lambda opponents:

14 Juni 2010

EJB 3.1, JUnit and GlassFish Embedded incl. JPA and JDBC DataSource

Today I have my JUnit tests with GlassFish embedded up and running and like to share how to configure it.

First we have a look at how to run the tests with the EJBContainer from EJB 3.1:

public class ConfigurationServiceTest {

    private static EJBContainer container;
    private static ConfigurationService service;

    public static void setUpClass() throws Exception {
        container = EJBContainer.createEJBContainer();
        service = (ConfigurationService) container.getContext().lookup("java:global/classes/ConfigurationService");

    public static void tearDownClass() throws Exception {

     * Test of findConfiguration method, of class ConfigurationService.
    public void testFindConfiguration() throws Exception {
        Configuration configuration = service.findConfiguration();
        System.out.println("From Configuration: " + configuration.getNextNewsletterSendDate());

The most important line is the lookup of the EJB:

Every found EJB is deployed to the embedded server and the JNDI name is built using java:global/classes and then the simple class name of the EJB.

That was all very straight forward. But then I had a problem configuring the JDBC datasource that the service needs using JPA. 
And again the solution was very simple. Just create the path org/glassfish/embed in classpath and add the domain.xml file from your "normal" GlassFish server. After copying you may want to do some cleanup with the file. You can delete everything that is under  <system-applications /> and  <applications /> because your application will run based on the classpath.

That's it.

When you want to us it with Maven2 simply put a new dependency in pom.xml.
Hint: In some situation it is best to have it as the first dependency!


Have fun!

19 Mai 2010

Google I/O: App Engine, VMware, SQL

In my opinion today at Google I/O two incredible announcements were made.

1. Google and VMware are working together on a PaaS clound:

Until yesterday I was sure that Java EE 6 will kill Spring Framework in the next few years, but now we have a clear statement for a PaaS (Platform as a Service) cloud based on Spring Framework. In contrast there is no PaaS solution based on Java EE 6. This will make Spring Framework more popular again!

2. Google App Engine Business

Google announced a business version of their app engine. This is not very revolutionary on a first view, but they will add SQL database support to the business app engine. This will make it possible to port existing applications to the app engine. Which was till now nearly impossible because one had to use BigTable and a migration from RDBMS to BigTable is a complete refactoring.

Spring and SQL DB in the Google app engine will make the killer platform for a lot of applications at a very low cost. I'm curios what the reaction of Oracle, IBM, RedHat/JBoss will be...

17 Mai 2010

Missing Feature in Bean Validation

After using Bean Validation for some month I had a problem that I couldn't solve.

It's not possible to add "dynamic" parameters to the validation message. For example if you want to pass the id of your entity that fails and want to use that id in your custom MessageInterpolator.

We solved this be adding the parameters at the end of the message separated by #. So we could extract them in our MessageInterpolator and exchange {0}...{n} to the parameters passed.

But in my opinion this is an evil hack!
My suggestion is to change the type of the message in the method interpolate of the MessagInterpolator to something like ValidationMessage that could have a collection of object as parameters.

I will post this as a feature request to the JSR 303 expert group.

16 Mai 2010

First Thing I'm Missing in Java EE 6 Web Profile

After several weeks weeks using Java EE 6 Web Profile I discovered the first missing spec: JAX-RS.

I'm currently developing a simple web application and now wanted to add an interface for a PHP CMS. But how to create an interface without web services capabilities?

I think I will have to move to a full featured Java EE 6 application just to have JAX-RS :-(

27 März 2010

NetBeans vs. Eclipse (Again)

Because of some driver problems I had to reinstall Windows 7 on my notebook (Yes, I use Windows!). This took a while and then I was ready to install my IDEs. I use Eclipse an NetBeans in parallel, depending on what the customer uses.

Again I recognized an extreme difference in the installation procedure. Here the steps I had to do:

  1. Download IDE and, hey surprise, GlassFish is bundled as well!
  2. Install it
  3. Run NetBeans
  4. Check out project from SVN. NetBeans asks me to download/install SVN. After a click and a restart NetBeans is ready to use.
  5. Start developing using Maven2, Java EE 6 and GlassFish
  1. Download Eclipse
  2. Download GlassFish
  3. Run Eclipse
  4. Decide if I want to use Subversive or Subclipse. I prefer Subclipse.
  5. Install Subclipse
  6. Install m2eclipse
  7. Install GlassFish integration
  8. Restart IDE
  9. Checkout project from SVN
  10. Start developing using Maven2, Java EE 6 and GlassFish
As you can see, NetBeans brings all you need and it's very easy to install and use. Where as Eclipse doesn't contain any plugins that are used these days in the industry (Maven2, Subversion, etc.)

To do a quick start I recommend NetBeans. And if you want to use Eclipse make a backup after you have installed all the plugins!

17 März 2010

How JavaBean Properties Should Look Like

During a discussion about JavaBean properties in JSF managed beans and entity classes I had an idea for simplify the usage of properties. Because specially in managed beans the getter and setter are annoying and make the code hard to read.

In my opinion the C# way is straight forward:

public class TimePeriod {
    private double hours;

    public double Hours {
        get { return hours; }
        set { hours = value; }

But for a simple case like this the C# way is still to complicated.
So why not use annotations and a new modifier called property. For example

public class TimePeriod {
@Get @Set
    property double hours;

With the annotations one defines if a property is read-write, write-only or read-only. The new keyword "property" defines how to access the property.I like the possibility in C# to use = operator for getting and setting the properties value. So "property" indicates that one can use = to access the value.

And if you don't like the default behavior you could still override the get and set method for the property.

NetBeans toString() Generator Plugin Moved

Due to the ambiguous information of Oracle/Sun concerning Project Kenai I decided to move all my projects from Project Kenai to Google Code.

Please find the NetBeans toString() Generator Plugin there.

03 März 2010

JPA and Bean Validation

Nice article from Antonio Goncalves about integration Bean Validation and JPA:

In JPA 2.0 the integration is defined but It describes an easy integration with JPA 1.0 as well.

09 Januar 2010

1000+ Downloads of NetBeans toString()

My NetBeans toString() plugin seams to be a great success.
This week I had more than 1000 downloads.

More information and download of plugin can be found here: