Enterprise grade Java.
You'll read about Conferences, Java User Groups, Java, Integration, Reactive, Microservices and other technologies.

Thursday, September 12, 2013

New Article in German Java Aktuell - Java EE 7

12:24 Thursday, September 12, 2013 Posted by Unknown No comments:
, ,
Once in a while I publish stuff. This one is for my German speaking and reading audience. Latest Java Aktuell isse, which is the mouth piece of German iJUG e.V. has published an article of mine about the new Java EE 7 release.

Mobile statt Cloud - Java EE 7
Java Aktuell 04/2013
[GER] Es hat nur wenig mehr als drei Jahre gedauert, um aus der „6“ eine „7“ zu machen. Gemeint ist die Versionsnummer der Java Enterprise Edition (EE). Ursprünglich war die siebte Ausgabe stark auf das Thema „Cloud“ ausgelegt. Die Pläne stellten sich erst spät als zu ambitioniert heraus. Somit enthält die am 16. April 2013 fertiggestellte Version nur punktuell grundlegend Neues und stellt eine konsequente Abrundung der bereits vorhandenen Funktionen dar. Am 12. Juni 2013 feierte Oracle das fertige Werk mit einem internationalen Launch-Event.

You can download the article free (PDF) of charge! Enjoy!

If you want to know more about it have a look at the website www.java-aktuell.de

Tuesday, September 10, 2013

Java Mission Control 5.2 is Finally Here! Welcome 7u40!

21:08 Tuesday, September 10, 2013 Posted by Unknown No comments:
, ,
It has been a while since we last heard of this fancy little thing called Mission Control. It came all the way from JRockit and was renamed to Java Mission Control. This is one of the parts which literally survived the convergence strategy between HotSpot and JRockit. With today's Java SE 7 Update 40 you can actually use it again.

Java Mission Control 5.2
The former JRockit Mission Control (JRMC) is now called Java Mission Control (JMC) and is a tools suite which includes tools to monitor, manage, profile, and eliminate memory leaks in your Java application without introducing the performance overhead normally associated with tools of this type. Up to today the 5.1 version was available within the Oracle HotSpot downloads which could only be received by paying customers from the Oracle Support Website. Todays release is the first release of Java Mission Control that is bundled with the Hotspot JDK! The convergence project between JRockit and Hotspot has reached critical mass. With the 7u40 release of the Hotspot JDK there is an equivalent amount of Flight Recorder information available from Hotspot. And having it finally makes sense. Beside hundreds of minor fixes and improvements the JMC Client is now build to run on Eclipse 3.8.2/4.2.2 and is also featuring a new JVM Browser with server-side subnotes. This makes tracking of running recordings and JVMs a lot easier.

Java Flight Recorder (JFR)
But the main and most important feature is the Flight Recorder. The Flight Recording feature work with events. Those events need to be produced by the underlying JVM. Hotspot has now reached event convergence with JRockit. That means that most useful information that was provided from JRockit is now also available from Hotspot. And because those are quite different JVMs; the information will in some cases be a bit different. The overall profiling overhead for your applications still stays at less than 2%. Usually much less. Which, considering the information you get, is next to nothing.

JFR with GlassFish 4
Lets get your hands dirty and try this with latest GlassFish. First change your glassfish4\glassfish\config\asenv.conf/.bat and add AS_JAVA=PATH/TO/JDK7u40 now start the domain and navigate to the JVM options. Or as an alternative open glassfish4\glassfish\domains\domain1\config\domain.xml and search for the relevant java-config tag and add the following two jvm-options:


Now restart the domain and look for the jdk1.7.0_40\bin\jmc and fire it up. If you're running on the same machine you should already see a list of available JVMs in the JVM Browser. If you expand the GlassFish node and double click the "MBean Server" node you get a nice overview over what is happening right now:

From there you can start a flight recording by right clicking the "Flight Recorder" node in the JVM Browser. Select the desired recording time and event settings (which now btw have a new template feature to pre select events :)) and click finish. After the desired timeframe the recording gets downloaded to JMC and you can look through the timeline and find bottlenecks.
A very small drawback is, that you can't run it with GlassFish 3. There is a know bug which got fixed for the 4.0 release about ordering of the jvm-options.
UPDATE 12/02/13: A coworker pointed me to a nice workaround documented in the originally mentioned bug. It's possible to set the required flags using debug-options and enable debug for the domain:
<java-config ... debug-enabled="true" debug-options="... -XX:+UnlockCommercialFeatures -XX:+FlightRecorder">

What is hot?
The best thing since sliced breed is, that you now have method profiling events! With the method profiling events you can find out where your application is spending the most time executing your Java code. This is, for instance, useful to optimize the application where the optimizations actually have an impact.

Further on you have an improved allocation profiling tab.You can now see per TLAB allocation with traces, and object being allocated directly in old space. That "new and improved" theme continues throughout the all tabs in the flight recorder. You get a File I/O, Socket I/O and many many more which provide plenty of insights.

Experimental Plugins
And the best part for me is that the team keep going with a bunch of experimental plugins. A new one was added called JOverflow - Heap dump analysis for memory waste. This plug-in allows Mission Control to do heap dump analysis, primarily to look for wasted heap space. There are several different anti-patterns JOverflow will look for, such as duplicate strings, underutilized collections etc. This plug-in also adds an action (for local connections) that will perform a heap dump and then visualize the heap dump with JOverflow. This is somehow a short term replacement for the Memleak Analyzer which you might know from JRMC. The D-Trace Plugins also got a major overhaul. You can find out more about it on Marcus Hirt's blog.

Download and Further Reading
You can grep the latest 7u40 download from the Oracle Technology Network Java SE Download Page. Java Mission control is already integrated and you're ready to run it.
If you need more information visit oracle.com/missioncontrol where you can find the links to the documentation and Eclipse update sites.

Friday, September 6, 2013

CapeDwarf - Google App Engine on Java EE

12:04 Friday, September 6, 2013 Posted by Unknown No comments:
, ,
I have many hobbyhorses. Coming all the way from the early Java EE specifications and having done the "cloud" excursion with Java EE 7 I was curious to see what newly announced CapeDwarf project has in stock to bring Google's Platform as a Service offering "Google App Engine" on premise.

The Story so Far
I did play around with App Engine. It was the first true PaaS offering for me back in the days. And I liked it. What I dislike is, that you have to check if GAE is playing nicely with your flavor of Java. A couple of days back end of June Google and Red Hat announced the official partnership working on the GAE TCK which sooner or later should bring the App Engine to Wildfly.

Installing and Configuring your Environment
Let's start right away. Get CapeDwarf and play around with it. In the core there is Wildfly or AS7 as most of us still know the JBoss Applicationsserver. CapeDwarf is only an extension module and needs to be build in. There are basically two ways of getting it: Grep the latest build from the downloads page which would be the Beta5 (released  2013-07-10) or build it on your own. I tried the last way first and it is supported by a very brief readme on the github project page but I wouldn't recommend doing this. It takes roughly 30 minutes (pure build time) because you also have to build the AS 7.2.0.Final yourself. If you get the zip distribution all you have to do is to unzip it and start the CapeDwarf enabled server via:

$JBOSS_HOME/bin/standalone.bat/.sh -c standalone-capedwarf.xml

This looks like an AS 7 start at first beside the fact that it is taking much longer because of the JGroups startup. At least on my machine. Anyway after that you have to add an admin user and log-in to the server console at http://localhost:9090/ and check if the extension is there by visitin the "Extensions" tab. Now you're all set.

Using the Guestbook Example Application
All left to do now is to fire up the IDE of choice (NetBeans in my case) and get a nice little demo project up and running. Lets stick to the guestbook example which also is part of the official gae-sdk. You should have Maven and Java 7 at hand already. The guestbook example is available as an official archetype and you can simply have it by using the following mvn command:

mvn archetype:generate -B
-DarchetypeArtifactId=guestbook-archetype -DarchetypeVersion=1.7.7
-DgroupId=net.eisele.demo -DartifactId=guestbook -Dversion=1.0 -Dpackage=net.eisele.demo

Everything you need in terms of dependencies is in central so you don't even have to configure another repository! Open the generated project right away and start to tweak some things. First you need to change the die appengine.target.version in the pom.xml to 1.8.3 Next thing is you need to add the relevant datastore indexes. As I understand it, GAE does this on it's own. CapeDwarf which relies on a couple of existing Red Hat technologies needs to be instructed to fire up the indexes. Add the datastore-indexes.xml to your src/main/webapp/WEB-INF/ folder with the following content:

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
    <datastore-index kind="Greeting" ancestor="true" source="manual">
        <property name="date" direction="asc"/>
If you add the <finalName>ROOT</finalName> attribute to the <build> section of the pom you're ready to go. Deploy the app via the management console or put it to the $JBOSS_HOME/standalone/deployments folder. There you go. Navigate to http://localhost:8080/ and watch the magic happen.

You could post greetings or even login with an email-address and leave personalized comments. And everything without changing a single line of code. You could even deploy the same piece of code to the App Engine. Further on, if you navigate to http://localhost:8080/_ah/admin/ you get a nice little admin console which gives you access to the underlying datastore.

Even Datanucleus plays nicely within this game and you could make the examples run by changing the javax.jdo.PersistenceManagerFactoryClass in the jdoconfig.xml to org.datanucleus.api.jdo.JDOPersistenceManagerFactory. If you now get the dependency versions right (jdo-api:3.0.1, datanucleus-core:3.1.5) and you use the right maven datanucleus plugin:

You're fine to go with that also. Give it a try. It is really easy.

Things to improve on for now
The implementation is limited at the moment. It seems as if the project team focuses on the official GAE-TCK. A majority of the APIs is completed and only nine out of 26 services aren't supported according to the CapeDwarf homepage. Given that I would have expected to see a little bit more documentation. For now this basically comes down to the official Google documentation. If you run into something special you're on your own. If you have questions regarding the TCK a newly formed Google Group covers them. Good new: The Project Lead Aleš Justin is responsive and helpful as I have experienced all Red Hat Java guys so far. If you are looking for examples there is a broad test coverage based on Arquillian in the CapeDwarf project. So this is a good place to start for now.

Google App Engine an Alternative to Java EE 8?
What is the bottom line? I would call the GAE infrastructure mature. Being launched in April 2008 and released to public late 2011 it had solid five years to grow to customer needs. Looking at the definitions from the cloud topic in early Java EE 7 specs and comparing them with what GAE already achieved is saddening. While EE has a very decent technical cut along application layers, GAE at least partly breaks this up into a service oriented way. While you see stuff like security spread nearly all over the place in SE/EE (JAAS, JASPIC, individual specs) GAE simply provides a Users API for User Management and an AppIdentity API for integration with other systems. Beside this it also provides APIs and abstractions for features that Java EE simply doesn't offer ready-made. I'm thinking about a Multitenancy API or something like the Capabilities API. If someone wanted to start lightweight on Google's PaaS in the past and tried to have a later migration to Java EE based on-premise hardware in mind he had to think carefully about mapping technologies and buying into Google specific services. As of today CapeDwarf already changed the rules significantly and lowered the vendor-lock risk.

If you look at the specification side it has it's drawbacks. Google is in charge. Exclusively. For now I don't see any advisory-board or comparable thing in place. So if Google decides to pull back (e.g. Reader disaster) many people would be stuck. The open TCK on the other hand at least makes the specification available free of charge to everybody (ASL2.0). And this is what basically made CapeDwarf and AppScale possible. For now this isn't the better Java EE at least for me. But given the fact that we are again looking into a cloudy future with Java EE 8 this could be a blueprint for new specifications which need to be done and also could be a nice guideline for something I would call "topic centric APIs". Taking care for the business needs and no longer only for the technology problems. This is going to be an interesting movement in the next few years and I am curious if some other vendors jump on that train sooner or later. And it is sad to see that Google pulled themselves out of the JCP and the active development inside the standards body.

Further Links and Readings
The Blog of the project lead http://in.relation.to/Bloggers/Ales
CapeDwarf on Github https://github.com/capedwarf/
CapeDwarf Downloads http://www.jboss.org/capedwarf/downloads
The App Engine TCK https://github.com/GoogleCloudPlatform/appengine-tck