Category Archives: Uncategorized

Trust in Java EE

In these days there is so much noise about Microservices and scalable architectures. We read about Verticals, Multi Threading and Fat Jars. I ask myself what is all that good for? Didn’t we have an architecture which is still providing similar concepts –  called the Java Enterprise Edition?

What is the idea behind Java EE? The main job of a Java Enterprise Server is to server resources to your application. This means a Java EE application sever provides resources like Database connections and security realms. As a Java EE developer you have not to think about how this is done. You just lookup – or in newer days inject – a JNDI resource. This resource can be a database pool, a Mail Session, a LDAP connection or something else. The application sever is responsible about managing, pooling and scaling of these resources. Why not trust in that concept?

There may be some cases where big companies are running there business applications in an awful architecture. Sometimes you can see a productive environment with many tomcat instances, each running a single piece of code from the business domain. For example there are several war artefacts, one for the customer service, one for the order management and another tomcat is serving the offer management. And each module is running in a single servlet bringing its own JDBC connector and security with hard coded configuration. I think you can agree with me that this is nonsense and bad practice.

So why not trusting in Java EE? If you are using this architecture in the right way you can deploy all 3 war modules from the scenario above into one application server. Each war module lookup or injects the same JDNI database resource. The application server is responsible to manage JDBC connections. And the important part here is that these JDBC connections are running in several separate threads outside of your servlet. So why not using this facilitation?

The other part we should think about is the business logic. If you put all logic into one servlet the code grows up with the time. This can not be managed well and took a lot of resources on your web server (each time the servlet is called). Ah! That’s it – we need more verticals, microservices and servers to bind each part of our business logic into a separate thread. Looks so, but again we missed one of the core concepts of Java EE – EJBs. EJBs are by far the most misunderstood concept of Java EE. The reason my be historically, because EJBs where at the beginning awful complex. But today EJBs are perfectly easy. You can put as much as possible of your business logic into several stateless session EJBs and the application server is doing the rest. EJBs are pooled in a container. This means they are running in separate threads, are pooled by the server and are transactional. You can’t implement such a concept easily by yourself. And at least Java EE application servers can also be clustered.  So there is enough playground also to set-up large server environments –  if you like…


Java EE provides an architecture that solves the main problems of modern web applications. Although Java EE is several years old, there is not reason not to trust in this architecture. In my eyes it is no wasted time to seriously deal with this technology and consider all the ideas and concepts. Thus, Java EE at the end may be the best architecture to build the big brother of Microservices –  Self-Contained Systems.

Please let me know if you can give me arguments why I should rebuild my business application from a Java EE platform into a new architecture style like  Vert.x, Wildfly Swarm or something else?

How To Debug Race Conditions

The last days I had a strange problem with one of my Java EE applications. One of my classes was not ‘thread save‘ and so my code run into a problem raised by a ‘race condition‘. It was hard to figure out what really goes wrong, because the fault occurs only in the productive environment and only one or two times in one month. So in this post I want to share some of my experience how you can debug Java EE code and test if your code is thread save or not.

Debugging a Multi-Thread Application

First of all you need to setup you dev-server into a debugging mode.  Read this posting to see how to debug WildFly which the Eclipse Debugging Tools.

If everything is prepared for debugging you should fist find a piece of code which can be accessed by multiple threads simultaneously. For a Java EE application this can be a method in a front-end bean running in the web container (e.g a request or session CDI bean) or a Session EJB running in the ejb container.

Now set three breakpoints in the first lines of your code to make sure you can watch the entry into your code by a single thread:


Starting multiple Threads

Now you can start the fist thread. Open your web browser and trigger your application to execute the piece of code your are interested in.  Eclipse will stop the thread on the first breakpoint. In my example code line 548:

eclipse_debug_multithread02The important part here is the thread number which indicates the first thread uniquely. To see what happens start over to the next breakpoint (in my example line 555).

Now lets start a second thread by opening a second browser window and trigger the corresponding piece of code again. In the Eclipse Debugger this is a little be tricky because the Eclipse Debugger will not automatically switch to the new thread. So you will not see any change in Eclipse. But when you go through the list of threads in the Debug View, you will see a second ‘suspended’ thread. You can expand the second thread and navigate to the code line this thread is waiting:


Now as you know both thread numbers you can see exactly what happens in each thread. Using the debugging tools you can now start over in your second thread to the third breakpoint in you code. Remember – our first thread is still waiting at the second breakpoint. You can check this in your code by switching between your threads. And this is the important part: You be now able to simulate race conditions between multiple threads in your code. This is a kind of super-slow-motion where you are the cameraman.

Singleton Pattern and Synchronized Method Calls

If your code is not thread save, you can possible run into the problem of a race condition. This means that two threads are observing for example the same member variables of a class. In my case this was the fact as I accessed my code in a static way and store values in static member variables. In the debugging scenario explained before you can watch this problem easily. To get rid of such a behaviour you can implement the singleton pattern. But be careful, this isn’t as simple as it may look at the first. A good solution for Java EE applications is the usage of the @Singleton Session EJB. This EJB type implements a singleton pattern and also synchronize all method calls per default. Again you can debug this with a multi-thread debugging session.

So I hope this short tutorial will help you the next time when you need to check if your code is thread save or not.


Windows 7 Update – Height CPU Usage

If a windows takes to much CPU usage and runs endless the following trick may help:

  1. run the tool ‘msconfig’
  2. disable the option ‘Benutzerdefinierter Systemstart’ -> ‘Systemstartelemente laden’
  3. select  under ‘Dienste’ the option ‘Alle Microsoft Dienste ausblenden’
  4. deselect all ‘Dienste’
  5. Restart Windows
  6. Run the Update Tool

When all updates are finished successfully the option “normaler Systemstart” can be enabled again in the msconfig Tool.


Building Websites with Markdown and Maven

If you want to setup a new web site, today there are a lot of frameworks and content management systems in the market. One of the most common is WordPress which can not only be used as a blog software but also to build pretty web pages. But WordPress has some disadvantages in my eyes. It is build with a lot of PHP code, you need a database and at least you will be attacked by masses of hackers. If you only plan to setup a small web site you can do this with pure HTML. But this isn’t an ideal solution if you want to separate content form design – which is a best practice in these days.  Continue reading

Open Source – what does it really mean?

Open Source is one of the most misunderstood domains in our new society. I just read an article about the failure of the sharing economy. The author closed with the idea, that really no one would like to share something if he doesn’t get something back which brings him into an better position. And this is not inhumane.
The failure of the sharing economy brings me to new thoughts about open source. I am working in a open source project since several years. What does it mean to me? It is not to give my work to other companies for free. We run a company which provides commercial services. These services mean: “Hey we have a cool fancy technology. If you like it, we can help you to get started“. And this is because software development is not one of the easiest things in our live.
So what I am sharing in my open source project is not the enterprise software to be used by the big industry for free. I just share my thoughts about problems in the area of software development. My thoughts are open for anyone who is interested in discussing those kinds of software problems. It’s like sitting in the pub and talking with someone about the last football match. Just sharing thoughts and come up with new ideas. That’s the meaning of Open Source.

Warum Aufgabenmanagement scheitert

In der heutigen Arbeitswelt sind wir es gewohnt, komplexe Aufgabenstellungen in kleineren oder größeren Teams zu lösen. Probleme, Aufgaben oder Projekte versuchen wir mal mehr, mal weniger erfolgreich zu strukturieren und die gemeinsame Arbeit daran zu vereinfachen. In der IT ist diese Disziplin der Teamarbeit sicherlich mit am meisten ausgeprägt. Es gibt unzählige Tools die uns bei der Koordination von Aufgaben in Projekten unterstützen. Manchmal gelingt es besser, manchmal aber eben auch schlechter. Warum ist das so? Warum kommen wir immer wieder mal an einen Punkt wo wir uns sagen ‘das hätte eigentlich besser laufen sollen’. Gerade in der IT versuchen wir dann meist mit Hilfe eines neuen Tools das Problem  künftig besser in den Griff zu bekommen – oder wenn wir richtig innovativ sind, programmieren wir uns gleich selbst ein solches Tool. Das ist übrigens auch der Grund warum es so extrem viele Projektmanagement Softwarelösungen am Softwaremarkt gibt. Continue reading

Maven Incremental hot deploy – a plugin for the Eclipse IDE

There are different ways how to deploy Java EE application into an application server like Glassfish or JBoss. You can deploy your application using a command line tool or a web interface provided by your sever. Or you can use the autodeploy feature which means that you simply copy your application into a specific folder of your server (e.g. ../domains/mydomain/autodeploy/ for Glassfish)

The Eclipse IDE provides a plugin called “Web Tools Plattform” (WTP) which supports the hot deployment functionality for some application and web servers. But if you are using the Maven build tool the Ecipse WTP feature did not integrate smoothly with the maven project structure. So is most cases the hot deployment feature will get lost and the development and deployment will become time intensive and frustrating. This is the moment where manik-hot-deploy comes into play. manik-hot-deploy is an Eclipse plugin which supports hotdeployment functionality for your maven java enterprise project. It is easy to configure and speed-up the development of web and enterprise applications.

Autodeployment vs. Hotdeployment (Incremental Deployment)

Most application servers like GlassFish? or JBoss are supporting two different modes of automatic deployment. The autodeployment and the hotdeplyoment (also called incremental deployment).


Autodeployment means that you simply copy a web- (.war) or enterprise application (.ear) into a specific directory of our application server. For Glassfish this is the folder:


When you copy an application into that directory Glassfish will automatically detect the new artefact and starts a deployment process. If the application was already deployed before a redeployment will be started.


In different to autodeplyoment the hotdeplyoment (or incremental deployment) will not deploy the whole application but parts of your application which are updated or changed during development. This is a powerful feature which can save you a lot of time during development. Incremental deployment means, that in the moment when you are changing a web resource (like a .xhtml, .jsf or .css files) this change is immediately transferred into your deployed and running application. So there is no need to build and redeploy the application.

The Manik Hot Deploy Plugin for Eclipse

See how to install and use the Mani-Hot-Deploy Plugin for Eclipse to find an easy way to autodeploy your JEE projects form Eclipse into your application server.