Getting started with SwitchYard 2.0.0.Alpha1 on WildFly 8.1.0.Final

I've been sticking my head into some hot RedHat technologies lately and among the many interesting parts I found SwitchYard. Without being disrespectful towards everybody wrapping their heads around SOA and service oriented architectures in the past, this has always been kind of weird to me as a Java EE developer.

In the past I've been building component oriented applications with what I had at hand. Mostly driven by the features available in the Java EE standard to be "portable" and easy to use. Looking back this has been a perfect fit for many customers and applications. With an increasing demand for highly integrated applications which use already available services and processes from all over the place (departmental, central or even cloud services) this approach starts to feel more and more outdated. And this feel does not come from a technology perspective but from all the requirements around it. Having this in mind this post is the starting point of a series of how-to's and short tutorials which aim to showcase some more diverse ways of building (Java EE) applications that fit better into today's requirements and landscapes.

What is SwitchYard?
It is a component-based development framework for integration applications using the design principles and best practices of Service Oriented Architecture. If you're expecting kind of a full-blown fancy BPMN/SOA buzz-word suite you're off by a bit. This is for developers and should make it comparably straight forward to use. It's been around for a while now and starting with latest 2.0.0.Alpha1 it is compatible with WildFly 8. Reasons enough for me to get you excited about it.

Installing SwitchYard into latest WildFly 8.1.0.Final
Download both, the switchyard-2.0.0.Alpha1-wildfly bundle and WildFly 8.1.0.Final from the project websites. Install WildFly 8 by unzipping it into a folder of your choice (e.g. D:wildfly-8.1.0.Final). Now unzip the SwitchYard bundle into the WildFly folder. Depending on the zip utility in use, you may be prompted whether existing files should be replaced.  Answer yes/all for all files being unzipped.
It's an alpha so you have to tweak the configuration a bit because of SWITCHYARD-2158. Open "JBOSS_HOME/standalone/configuration/standalone.xml" and search for "org.switchyard.component.camel.atom.deploy.CamelRSSComponent" and change the package from "atom" to "rss". Now go ahead and start the server with "JBOSS_HOME/bin/standalone.sh/.bat".
If everything worked correctly you should see a message like this:
09:18:25,857 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.Final "Kenny" started in 3712ms - Started 210 of 259 services (81 services are lazy, passive or on-demand)

Building and Deploying the Bean Service Quickstart
If you want to get your hands dirty you can easily start with the packaged applications in the "JBOSS_HOME/quickstarts/" directory of the distribution. A simple one is the bean-service example. It makes use of one of the core components of SwitchYard, the Bean Component. It allows Java classes (or beans) to provide and consume services. And therefore you can implement a service by simply annotating a Java class or consume one by injecting a reference directly into your Java class.
And because the Bean Component is a standard CDI Extension, there is no need to learn a new programming model to use it. It's just a standard CDI Bean with a few more annotations.
For existing Java EE applications this means, that you can expose existing CDI-based beans in your application as services to the outside world or consume services within your bean by just adding some more annotations.
First things first. We need to tweak around a bit in the project pom.xml to make this work. Go to the build section and replace the "jboss-as-maven-plugin" with the latest version of the
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
Now run "mvn package" to download all dependencies and execute the tests. It should just work fine and state:
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
Let's deploy it to our WildFly instance by issuing "mvn -Pdeploy install". The WildFly console finally lets you know about the successful execution:
10:19:44,636 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "switchyard-bean-service.jar" (runtime-name : "switchyard-bean-service.jar")

Quick Test For The Application
A very quick test is to execute mvn exec:java which will execute the BeanClient class and fire a SOAP request towards the deployed service. The output should be:
SOAP Reply:
<soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><env:header xmlns:env="http://www.w3.org/2003/05/soap-envelope"></env:header><soap:body><ord ers:submitorderresponse="" xmlns:orders="urn:switchyard-quickstart:bean-service:1.0
"><orderack><orderid>PO-19838-XYZ</orderid><accepted>true</accepted><status>Orde
r Accepted [intercepted]</status></orderack></ord></soap:body></soap:envelope>

That is it for today. The next parts will examine the sample application in a bit more detail and install the tooling and introduce you to various other components. If you can't wait, check out:

Win a free eBook copy of WildFly Performance Tuning

This is a seriously good start into a new area. I thought you might be interested in winning Packt's latest book about WildFly Performance Tuning. So, this is the contest to make it happen.
I have 2 eBook copies of WildFly Performance Tuning to be given away to two (2) lucky winners.

Here are the Rules
- The contest is running from today (07/09/14, 5:45a UTC) to next Wednesday (07/16/14, 5:45a UTC).
- Answer the three questions below correctly about WildFly and put down a comment on this blog with the answers.
- If more than three correct answers are posted, I will let my daughters draw the two winners.

The Questions to Answer
1) When was WildFly 8.1.0.Final released?
2) What is the name of the Red Hat project, that offers help with Java EE application migration?
3) Who wrote the WildFly Plugin for NetBeans 8?

Content of the Book
Chapter 1, The Science of Performance Tuning, talks about what performance tuning is all about and how it can be applied within an organization.
Chapter 2, Tools of the Tuning Trade, introduces some useful Open Source tools to use when performance tuning anything covered in this book.
Chapter 3, Tuning the Java Virtual Machine, covers what the engine of Java is and how to tune it as well as all other Java-based applications.
Chapter 4, Tuning WildFly, explains what can be tuned in the WildFly
Application Server.
Chapter 5, EJB Tuning in WildFly, talks about how Enterprise JavaBeans can be tuned.
Chapter 6, Tuning the Persistence Layer, covers how to design an effective database as well as how to tune JPA and queries.
Chapter 7, Tuning the Web Container in WildFly, explores Undertow—the blazingly fast, new web container in WildFly—and discusses how it can be tuned to become even better.
Chapter 8, Tuning Web Applications and Services, covers numerous tuning tricks and tips surrounding the web applications and services based on Java EE.
Chapter 9, JMS and HornetQ, explains how JMS works and can be tuned in HornetQ, the JMS provider of WildFly.
Chapter 10, WildFly Clustering, explores tuning in a clustered WildFly, HornetQ, and Java EE components.

About the Author
Anders Welén embraced the object-oriented techniques of the Java language early in life, and later evolved to Java Enterprise specifications. As a true believer and evangelist of Open Source, he naturally discovered the JBoss Application Server,
which led to years of providing expert consultation, training, and support for the JBoss and Java EE infrastructures.

Good Luck everybody!

Farewell msg systems …

.. and thank you for amazing 14 years. It's true: I've been within the msg group for an incredibly long time  and have been working in the Java/Java EE space almost all of it. Next Friday (07/11/14) will be my last day. Now it is time to move on.
I've been working with customers and internal Java EE projects all over the place, blogged, authored articles and have been speaking at conferences a lot. The passion for Java and mostly Java EE related topics is burning even hotter these days.

I'm more than proud to announce that as of calendar week 29 (7/14/14), I'll be joining Red Hat as Developer Advocate in Arun Gupta's team.
My main topics are technologies related to Red Hat JBoss Middleware including WildFly and the broader JBoss technology stack. So, I will be blogging, speaking and spreading the word about the most important and relevant parts in today's Enterprise Java world. There's no need to be afraid of this blog turning into a sales slide-deck. As you're used to, I'll mostly stick to technology and conference reports. So you don't even have to update your bookmarks as this blog is here to stay.

So, if you have ideas, requests, wishes or if you're just hungry for something new, just give me a ping on @myfear or leave a comment in this blog and I'll be more than happy to respond. Just reach out to me.

Arun and Markus at JavaLand 2014

"Mad Matter: "Have I gone mad?"
Alice: "I'm afraid so. You're entirely bonkers. But I'll tell you a secret. All the best people are.”
Lewis Caroll, Alice no País das Maravilhas

Java EE 8 – Deliver More Apps to More Devices

If there's one thing I dislike about summer, it is the fact that there isn't much news to share or talk about. Who ever decided to put the Java Day Tokyo into this boring time of the year did a pretty good job and gave me an opportunity to write a blog post about new and upcoming Java EE 8 specification enriched with some more thoughts and pointers.
As announced on the Java EE 7 EG Mailinglist beginning of June the new EE 8 JSR is going to be filed shortly (before JavaOne).

Contents of EE 8
Unlike the first version of EE 7 which was totally dominated by the word "cloud" and later re-aligned with the hard facts, this new Java EE version will basically stick to three different areas of improvement.

  • HTML 5 / Web Tier Enhancements
  • CDI Alignment / Ease-of-Development
  • Cloud Enablement

All three can be seen as a continued evolution of what EE 7 already delivered and there is no real surprise in it at all. Head over to The Aquarium to read more about the details.

Cameron Purdy about EE 8 at Java Day Tokyo 2014

Hidden Gems - What might come up at JavaOne
The Java Day Tokyo was held recently and with Cameron Purdy as a keynote speaker about Java EE and it's general direction (mp4 download, 363MB) this probably was one of the first chances to see, what will be the overall story for JavaOne with regards to the platform. As Oracle should have learned the Java community isn't interested in big and unpleasant surprises. Strategic directions are communicated and prepared a bit more carefully. We all have seen and heard about the IoT hype and the efforts everybody puts in it. This obviously also seems to have some outreach into Java EE. Beside the general topics and contents of EE 8 the Purdy keynote also contained a slide titled "Powering Java Standard in the Cloud - Deliver Mode Apps to More Devices with Confidence". 

Java Standards in the Cloud.
And yes, you are correct about thinking that this is EE 7 coverage. It actually is. But at least for me it is the first time, that individual features have been isolated from individual technical specifications and put into a complete, strategic picture outlining use-cases in the enterprise. It will be interesting to see, if there is something more like this to be shown at JavaOne and how much IoT we will see in EE 8 when it finally hits the road.

I’m speaking at JavaOne 2014, September 28 to October 2, 2014 in San Francisco, California, USA

Just a short 104 days to go until the number one Java event is going to happen again. JavaOne opens it's doors again beginning 28th of September till the 2nd of October this year. After intense months of work in the program committee for both the Server-side Java and the Java in the Cloud track, where we dug through all the proposals the final program has been selected and the notifications have been send out.

And I am proud to contribute again this year. After the intense event last year, this is going to be a bit more relaxed with only one session.

Session ID: CON1747
Session Title: JavaScript in the Enterprise
Session Abstract: Instead of exclusively using JavaScript on front-ends what else can be done with it on Java EE servers? Looking into Nashorn, Avatar, Scripting JSR and other possible options of also using JavaScript as an enterprise workhorse.

Beside this I am going to contribute to the NetBeans day and moderate the "Free Java Tools for Maven and Java EE" panel.

There'll be tons of amazing sessions in the content catalog and if you haven't you should register today!

Review: "Java EE 7 with GlassFish 4 Application Server" by David Heffelfinger

The third edition of David Heffelfinger's Java EE book has been recently released. This updated edition is covering the latest Java EE 7 Platform. Thanks to Packt Publishing for giving me a review copy to look at.

Abstract
This book is a practical guide and follows a very user-friendly approach. The book aims to get the reader up to speed in Java EE 7 development. All major Java EE 7 APIs and the details of the GlassFish 4 server are covered followed by examples of their use. If you are a Java developers who wants to become proficient with Java EE 7 this book is ideal for you. Readers are expected to have some experience with Java and to have developed and deployed applications in the past, but don t need any previous knowledge of Java EE or J2EE. It teaches the reader how to use GlassFish 4 to develop and deploy applications.

Book: "Java EE 7 with GlassFish 4 Application Server"
Language : English
Paperback: 400 pages
Release Date : March 26, 2014
ISBN-10: 1782176888
ISBN-13: 978-1782176886

The Author
David Heffelfinger (@ensode) is the Chief Technology Officer of Ensode Technology, LLC, a software consulting firm based in the greater Washington DC area. He has been architecting, designing and developing software professionally since 1995 and has been using Java as his primary programming language since 1996. He has worked on many large scale projects for several clients including the US Department of Homeland Security, Freddie Mac, Fannie Mae, and the US Department of Defense. He has a Masters degree in Software Engineering from Southern Methodist University. David is editor in chief of Ensode.net, a website about Java, Linux, and other technology topics.

The Content
This is actually the third edition of the book. All you need to know about Java EE 7 and latest GlassFish 4 release is packed into 11 chapters. Ranging from a getting started introduction with GlassFish to developing with latest Java EE 7 core technologies, like JSF, EJB and such it is also covering how to secure your applications. The 400 pages bring a net content of 313 real content (removing preface and appendix kind of stuff). It is a fast paced tutorial for Java EE 7.

Writing and Style
 If you are used to technical documentation you shouldn't struggle with this book. For a non native speaker it reads very easy and I didn't find very many complex sentences which stopped my reading. The examples always interrupt the overall reading flow but this book isn't meant to just be read. You need to get hands on the sample code and learn to use it.

Conclusion and recommendation
The book is keeping things simple enough to make it easy to start with almost the complete platform at a beginner level, summing up the concepts and without getting intimidated. The large amount of sample code, examples and pictorial representations improve the understanding of the content a lot.
It is an easy read and you can quickly work your way through it. Go get it, while it is hot!

JavaOne 2014 – Some First Analysis on Submissions

Time is running away these days. So many things happening in parallel and of course the most important Java conference is in the middle of everything. JavaOne 2014 closed the CfP doors already and voting is well underway. There are very few things the Program Committee is allowed to talk about but after having skipped that kind of analysis last year it was time for me to ask for permission and so I can start to spread some excitement about the content. Please keep in mind, that every number you see in here are just percentages; there is not a single hint on concrete counts or other numbers in here. It's all about proportions and overall weight. And one last remark: This is the complete overview about the submissions. The final conference program will be shaped out of it. A big "Thank you!" to the program chair Stephen Chin who was kind enough to gave his permission for publication.

Submission Types
A good starting point is the overall distribution of submissions over the different session types. Speakers could select any of four different types for their submission. The classic session, a BoF (Birds of a feather) a tutorial or a HoL (Hands on Lab)
Not a big surprise that most of the submissions are sessions (75%). This is slightly more than in 2012 (70,14%) Second most proposed content are BoFs. Followed by HoLs and Tutorials. Even if this sounds final for now the proportions might change because types get switched on request of the program committee.


Submissions per Track
Beside the non surprising type distribution the overall spread per track is another important figure. What is moving the community these days and which tracks got the most attention? There are nine different tracks to pick from. Clients and UI, Core Java Platform, Internet of Things, JVM Languages, Java and Security, Tools and Techniques, Server-Side Java, Java in the Cloud and Agile Development.


Very few proposals are moved around from track to track during the voting process but it happens. Spread out over the tracks is comparably equal. Slight leader is the "Tools and Techniques" Track. But the overall distribution doesn't allow to identify a clear leader.

Oracle vs. Non-Oracle Submissions
And the last two metrics I'm going to look at should answer the question about Oracle's involvement in general. Many people still believe that the JavaOne content is mostly driven by the company behind it. First of all, take the time to see and feel it for yourself. There is still plenty of time to register and take the chance to attend this amazing conference.


Exactly 70% of the proposals come from the broader Java community. Only 30% have been proposed by Oracle employees. Compared with the 2012 numbers this is only marginally worse by 1%. Note, that this only includes the proposals where the first speaker is an Oracle employee. I was asking myself the question if there is some track Oracle explicitly jumps in:


Overall answer: Just a bit ;) There are only two tracks where there are significant more proposals from Oracle than from the community. Internet of Things makes the most significant different and Clients and UI marks the other spot. Given all the latest hype around both topics this is anything but surprising. I am very pleased to see, that the Tools and Techniques track is completely owned by the community. My interpretation: It's pretty clear who knows how to use Java right ;)

Conclusion
JavaOne is once again going to be a great, community driven conference with a lot of awesome content! If you haven't done so take a look and register! The final program is going to be announced in a few weeks and there still is plenty of time to find a flight and a hotel near by. Save the date: September 28 – October 2, 2014! And don't forget to follow @JavaOneConf or Like the JavaOne FB page and keep up to date by reading the official blog!



XRebel on GlassFish 4

The cool Zeroturnaround guys recently opened the private beta for their latest product which is an interactive and live profiler for your Java EE apps. Anton showed me the M3 at DevNation and I was curious to get my hands on it. Here is the first test-drive and some screenshots.

Getting It And Setting It Up
First thing to keep in mind is, that it is a private beta. So you have to apply online to get access to it. After you've been approved you get an email with a password and URL to download the roughly 5MB large ZIP file which comes with a single jar and a bunch of text files. You can download the first documentation as a PDF and there is not much more than this for now. Setting it up also is very straight forward. As usual the jar has to be registered as a java-agent. In GlassFish you typically do this at the JVM settings (-javaagent:D:/path/to/xrebel.jar). For convenience reasons I decided to replace the debug feature and automatically activate XRebel while being in debug mode.


If that is done you're ready to go. All you need to do is to install your favorite application and give it a try. I decided to use latest EE7 DDD-sample project developed by parts of the GlassFish team: Cargotracker. Clone the SVN from Java.net and import it into NetBeans 8. Build it and deploy it to GlassFish. Point your browser to http://localhost:8080/cargo-tracker/ and you can see the first XRebel magic happen.

First Impressions
Let's have a look at what XRebel can do for you.


The tiny little control-panel is integrated in all pages you navigate through and gives you access to all kinds of runtime information. But first of all lets tweak the settings a bit and reduce the inspected number of classes a bit by configuring the package hierarchy we're interested in:


Beside that you can also tweak thresholds and notifications on the settings page. After you've done that you can redirect your browser to the public landing page of the application (http://localhost:8080/cargo-tracker/public/track.xhtml) and watch XRebel do it's magic. A click on the session symbol brings up the HttpSession details:


The dialog let's you inspect all the objects placed in the session and size. The little icon in the control panel keeps track of growth and alerts you if something unexpected happens. Even more impressive is the SQL inspection.


You can drill down to individual SQL statements, see the complete statement including resolved parameters, affected rows, execution times and execution timestamp. A tiny search box let's you specifically search for expressions and if you don't want to see the complete call-stacks you can simply switch the tab and look at all the queries as a one-pager.
The newest milestone M4 also has an exception tracer:


Which gives you a better parsed result of the occurred exception and little more details about the exact path where it happened.

Bottom Line
It is an amazing little helper. Minimal intrusive. No configuration in your application and still keeps track of most of the critical things you're interested in knowing. I'm curious for the upcoming betas and of course of the final product and it's licensing. Keep up the good work guys. I love your creativity when it comes to making better tools for developers.

Trip Report DevNation 2014

It's been an amazing week. Being announced as a features speaker put some more pressure as usual on me. But heading out to San Francisco for the second time this year was amazing. The typical hazels with a 10+ hour flight and immigration are easy to leave behind when you arrive in sunny and warm weather.


The inaugural DevNation happened this year being the new open source, polyglot conference for application developers and maintainers. Directly next to RedHat Summit in the famous Moscone Center. The speaker lineup was amazing and session titles were pretty new, too.

Moscone promised to be a prominent and well know location for this brand new conference. Even if the competition on Java events and conferences in the Bay Area is amazing RedHat managed to pull of something very attractive here. There has been plenty of space for people to hang out and the session rooms were close to each other to prevent longer walks around. The opportunity to drop into the Summit occasionally and see the huge exhibition area also added to the positive mix. Generally the distance between the developer centered DevNation conference and the JBoss Developer Lounge was kind of negative. I'd preferred to have some more JBoss action closer to the conference. Beside this the attendees had plenty of time to talk and hang out with speakers and organizers. It was a pleasure to be there and I am really looking forward to next years conference! Find some impressions from my visit in the G+ album.
G+ Album DevNation 2014

Happy 8th Birthday Java!

It's been another longer journey but yesterday, exactly two years, seven months, and eighteen days after the release of Java 7 we now have production-ready builds of Java 8 available for download! This new major release contains several new features and enhancements that increase the performance of existing applications, make it easier to develop applications for modern platforms, and increase maintainability of code. Here is a brief overview about my personal highlights.

What's new overall?
Several areas of the language itself, profiles, security, JavaFX, tooling, scripting, Date and Time, concurrency and a more or less lengthy list of things changed or got added. More than 8.000 bugs and features have been addressed and be incorporated into this release. The complete list can be found in the official release-notes.

Java Mission Control 5.3
One of the highlights is the new Java Mission Control release. It is bundled with the JDK and comes with a separate list of enhancements in it's own release-notes. Find the complete documentation as part of the official Java SE 8 documentation.

Compact Profiles
The newly introduced profiles enable reduced memory footprint for applications that do not require the entire Java platform. The javac compiler has a -profile option, which allows the application to be compiled using one of the supported profiles. The three are additive layers, so that each Profile contains all of the APIs in profiles smaller than itself. The compact profiles feature is useful in small devices with less hardware power.
And yes, I am personally still totally frustrated that Jigsaw will probably never see the light. But I am happy to be proven wrong on that.

Java Date-Time Packages
Thank you Stephen! Thank you for this great piece of work. TimesTen is the new Date and Time API in Java 8. Clear, Fluent, Immutable, Extensible. There are two basic ways to represent time. One way represents time in human terms, referred to as human time, such as year, month, day, hour, minute and second. The other way, machine time, measures time continuously along a timeline from an origin, called the epoch, in nanosecond resolution. See the official tutorial for more examples and usages.

Good Bye PermGen!
Removal of PermGen. Full stop. It's gone! YES!

Security Enhancements
More and stronger Algorithms, TLS 1.2 default and further enhancements.

Nashorn
Java 8 is co-bundled with the Nashorn, which is an implementation of the ECMAScript Edition 5.1 Language Specification. See the user-guide for all the details.

Happy 8th Birthday Java!
Congratulations to everybody involved. Especially the Adopt-OpenJDK community which was driven by the London-Java-Community and supported the Date-Time efforts by providing tests.

Veröffentlicht in Java |

JavaOne CfP 2014 – Open for Business

This time of the year. Finally. It was about time. The 2014 JavaOne Call-For-Papers opened a few days back. And it is going to be a great one. Plenty of changes upcoming and it will have a huge focus on community speakers.

The rolling acceptance process from last year is back, so submit early!

A quote of mine sneaked into the advertising emails ;)
There is a new dedicated track for Agile development this year, making a total of nine Java tracks.  This year's tracks are:

• Clients and UI
• Core Java Platform
• Internet of Things
• Java Virtual Machine Languages
• Java and Security
• Tools and Techniques
• Server-Side Java
• Java in the Cloud
• Agile Development

The call for papers closes April 15th at 11:59 p.m. PDT  and there is no time to waste. The best of the best speakers from the Java/JVM ecosystem will be there and if you look at the submissions from 2012 you see that most of the content comes from the community. As usual, speakers will receive a complimentary pass to JavaOne with an accepted talk.
Go ahead and submit some awesome talks!

Abandon Fish! Migrating from GlassFish to JBoss or TomEE

I'v been a bit busy lately writing and reviewing stuff and didn't really had the chance to wrap up content for my blog. But things will change again and I am truly looking forward to that. So this is just a small reminder about one of the latest things I've been working on. RebelLabs published their latest report yesterday and it was my pleasure to put some efforts into it.

Since a while the GlassFish community is a bit uncertain about the future of GlassFish and many developers are looking into alternatives. There are plenty of recommendations backed by vendors and evangelists. And nobody looked into the details and problem areas. It was time to change that and a bunch of people put together their thoughts and experiences about what it takes and which would be the best migration target. The outcome is the Abandon Fish! report. You can get it for free (at least for the price of your email if you want the PDF) and it contains all about the history of GlassFish, an assessment of the political situation and influencing parameters and a solid analysis about the different containers and reference implementations used on different servers. The outcome are 34 pages, beautifully designed and easy to read which guide you through the first steps and give you very good hints on what to expect when trying to migrate your existing applications from GlassFish to WildFly or TomEE.


"Continuous Enterprise Development in Java" by Andrew Lee Rubinger and Aslak Knutsen

I've been doing book reviews since some time now. But this is a special one. Back at JavaOne I ran into Aslak and Andrew and we had a chance to talk about their latest book project which has been floating around the interwebs since some time now.

Abstract
Take a use-case approach to Enterprise Java development, and discover how to program more effectively. This practical book shows you how to perform continuous development, using a testing platform the authors built with the JBoss community. Known as Arquillian, this platform acts as the missing link between testing and development.

Andrew Lee Rubinger and Aslak Knutsen demonstrate how testing is the very foundation of development—essential for learning and critical for ensuring that code is consumable, complete, and correct. Whether you’re learning a new technology, debugging broken behavior, or laying down new code, Arquillian helps you document your project in the form of test cases.

Book: Continuous Enterprise Development in Java
Language: English
Paperback: 222 pages
Release Date: February 20, 2014
ISBN-10: 1-4493-2829-6
ISBN-13: 978-1-4493-2829-0


My Interview
Thanks for taking the time talking to me. We know each other since a while mostly from the Arquillian Project. It was the first to have a ton of documentation beside the awesome testing features.
Now you are writing a book "Continuous Enterprise Development in Java" which is about testable solutions with Arquillian. Let me ask you some questions about it.

What is the book all about? Putting guides together? What was your motivation?

In building out the Arquillian Test Platform, we set out to make full-scale integration testing approach the simplicity offered by unit tests.  Historically, Enterprise Java has been cumbersome to validate in what we call a “real” runtime: one that closely mirrors how it will run in production.  Spring and Java EE both offer POJO programming models which facilitate the re-use of our business objects outside a backing container, but we feel strongly that testing outside of the proper context can lead to misleading results.  Only when we plug everything in together can we be assured that things are working properly, and that applies to both the code you write *and* the code you rely upon from an application server.
As our community grew we continued to build out extensions and guides for Arquillian which would offer instruction not just in applying Arquillian tests to Java EE, but explaining some ways to piece together Enterprise Java applications as a whole.  While there are plenty of books about a single technology - Andrew has written a revision of “EJB 3.1” from O’Reilly, for example - we found that our users were coming to us to learn about Java EE in general.  This grew our mindset that “testing is development”, and the book is a natural extension of the guides we’d built off for Arquillian.
In short, we felt that there wasn’t a book which broke down a complex Java application into layers and explained how they were wired together and tested, so we wrote one.

You're using a comprehensive example app throughout the book. What is GeekSeek all about and why did you choose it?

From the onset, we knew we wanted our examples to be more than simple toys.  We wanted to address the concerns of a developer charged with delivering a complete application: how do you validate asynchronous components?  What’s a good way to expose a true RESTful interface for your services?  How may a UI call the services layer and how do we ensure the rendered response is correct?  How do alternative domain models factor into the equation; should they be used and if so, when?

So we needed some single application which would allow us to address the use cases we wanted to explore without feeling like we were overengineering for the sake of example.  It turns out that the excellent Lanyrd service, one we use to track our own conference involvement, provided many of the features we needed to cover, so we created the GeekSeek example application as an homage of sorts to Lanyrd.

It was extremely important to us to deliver a self-proving example: one that could be downloaded and built by a user, but also ran in our own continuous integration environment and lived on a production server, so GeekSeek is the manifestation of that idea.  As developers we learn by doing, and this application is proven to work by nature of its being served up live.

Did the book help improve Arquillian? It is the best kind of "eat-your-own-dog-food" ... did you find stuff, that needs to be fixed while writing about best practices? Any war-stories to tell?

To be honest, we didn’t end up coming across too many issues with Arquillian by writing this book or GeekSeek; we’d waited until ARQ had reached a level of maturity before embarking on a large project to document its use in practice.  We did, however, encounter a series of known limitations, for instance the lack of Suite support, in writing.  Most of these issues haven’t yet been addressed because they’d require API changes in Arquillian which would break backwards-compatibility, and we have them on deck for a major version 2.0 when the time is right.

One bit I found particularly interesting is the idea of a Modular Test Suite. E.g. Module X adds Feature A to the app.  Now it’s possible Module Y is affected by these features on a test level. Why can’t Module X provide a Test Module to help Module Y? Security is a good example. Module Y doesn’t know about security, but if the Security Module is included, Module Y’s test suite starts to fail. Now if you want to explore the idea that a single test can run under multiple configurations (e.g. on a Module level and on an App level) like we do in the book, you would need some helpers to get around the new Security constraints. But what if the Security Module provided a Test Extension? In short, your own Modules provide Test Services / Management to the other modules.

Right, in many cases we found the warts inherent with Java EE or using Maven to manage the builds, and we tried our best to outline those and show some possible workarounds.

You're using all the latest and greatest. Including a REST/HATEOS driven backend for an AngularJS frontend. Do you believe that server side UI generation is dead?

No, server-side generation of the UI certainly has a place, as does client-side.  When you deal with dynamic elements only via JavaScript, this tends to give way to the common “loading” syndrome when the page is first rendered and then a series of async calls are made to pull in data.  On the other end of the spectrum, server-side generation can lead to a UI-only approach where services don’t need to be exposed in a RESTful fashion, and may in some cases be more resource-intensive than is necessary.  As with anything, we recommend that developers be aware of the strengths and limitations of each approach and choose solutions that best fit your requirements; sometimes a hybrid approach might be best.

In our case for GeekSeek, we’d simply felt that it was worth showing how to use the services of Java EE without necessarily using JSF for the view layer.  Having Angular tap into our RESTful interface to get at the backend data was a logical choice for us.

The book uses Java EE 6 as technology. And honestly I believe you did a great job. What do you think about Java EE generally and the improvements we got with EE 7 particularly. Wouldn't that have made your life easier?

It’s important that developers judge Java EE fairly; it’s aim is to standardize where appropriate and bring together a wide swath of disparate technologies.  It intentionally leaves choice to vendors in a number of areas, and by nature of being a standard cannot necessarily evolve as quickly as some may like, as that would cause too much instability inbetween major releases.  So it provides a very nice base upon which to build, and affords choice to the developer.

With that choice can come confusion, which is a large motivation for our book.  We look to illustrate a few ways of bringing the whole picture together.

Java EE 6 did have some limiting factors which we encountered and devised custom solutions to address.  For instance, JAX-RS 1.1 does not define interceptors, so we added a CDI-based interceptor chain to our REST layer.  And CDI 1.0 defines beans.xml metadata per archive with no global ordering or configuration, so we again added our own chain to address this.

WildFly was just certified as EE7-compliant during the book’s production process, and EAP will follow later, so we’ll look to provide updates to the application as time progresses; that’s why we’re releasing GeekSeek initially as an EE6 application.

You point your readers to JBDS and Forge for development. Honestly guys, which IDE are you using and why?

Aslak: Eclipse. For 15 years or so. I’m getting old, too many shortcuts built into my brain to change ;)

ALR: I use both standard Eclipse and the JBDS toolset, as well as IntelliJ IDEA Community.  It really depends upon what I’m doing; I love IDEA for most development and find it more resource-efficient, but I like m2e in Eclipse when I’m dealing with Maven dependency issues, and JBDS when doing anything with Forge or OpenShift because of the nice integration there.

The code runs on WildFly which isn't exactly a surprise. Do you test on other app-servers? Arquillian has a broad range of container adapters and I somehow expected to see some more here.

This again hits at the nature of Java EE; applications in compliance to the platform still need to run somewhere, and vendor differences start to show up when you put together a non-trivial application.  While porting between WildFly and EAP is generally a relatively-simple endeavor, there are still enough differences that running the exact same codebase on both targets requires some thought and intelligent implementation.  These gaps grow in orders of magnitude once you start to incorporate servers offered by other vendors, so for the sake of simplicity in delivering one source tree without forks to customize for individual application servers, we chose the community WildFly and free-for-development EAP (and its OpenShift cartridge) as runtimes.  We absolutely encourage our readers to port to their application server of choice and share their patches or experiences with us!

The book and source are licensed under Creative Commons. So, basically free to everybody and accessible on https://github.com/arquillian/continuous-enterprise-development. Why do you still do a printed version? What is the benefit of buying one? 

It’s really simple; we wanted the book to get into the hands of as many developers who might benefit from its lessons.  O’Reilly has a global reach and streamlined process to deliver to large online retailers and traditional brick-and-mortar stores, and they were open to our desire to deliver the text under an open-source license.  They additionally provide editorial and graphics work to really help deliver a more polished product than we’d have done on our own, so we decided to partner with them in the name of getting a higher-quality work out to as many people as possible.

I've always wondered how much work it actually is. Did you spend all your evenings on it? 

Aslak: I would say, roughly 2 months full time. The problem is when it’s not heads down full time, you lose so much built up contextual information along the way so it gets harder and harder the longer it goes between each write session.

ALR: Exactly; the work itself isn’t terrible in quantity, but when you couple it with a day job and have to deal with constant context-switching, it’s easy to let the book occupy more mental space than the actual time it takes to deliver would indicate.  It’s also not the kind of thing that you can do mindlessly; like software, writing requires a decent design phase and constant iterations to align your objectives with the code, and explain in a fashion that’s hopefully concise and complete.  It’s an exercise to our readers to judge how well we executed there. :)

WildFly 8 vs. GlassFish 4 – Which Application Server to Choose.

It's been a while since my last blog. I've obviously been busy with different things including my main job. After some more questions regarding the right choice for application servers cross my way it is the right time to pick this topic up again and share my thoughts.

One of the most read post on this blog is the post about which Java EE 6 application server to choose. I've been looking at a bunch of criteria and knocked down the different certified servers according to a very basic but common pattern. Given the main guideline that each server should be available as OSS and commercially supported variant the post concludes with recommending both GlassFish 3 and JBoss AS7 as valid choices. After the GlassFish roadmap updates from last November the situation seems to have changed and many people tend to accept that AS7/WildFly now remain the only alternative. Today I'd like to shift the focus on this a bit and try to put the discussion back into a more strategical context and elaborate further on the impact on the GlassFish vs. WildFly decision as of today.

Basic Strategy Principle for Java EE Applications
Beginning with having made the decision to develop a new application based on Java EE you already assumed a couple of things. Java EE is called an industry standard for a reason. It means it is widely adopted and still not officially captured by one of the official standards or standardization organisations like DIN/ISO or IEEE. The JCP provides rules and regulations for it and governs it along a broad contribution from different individuals and organizations. Calling it an open industry standard is common and valid for me. You may weight the difference between both on your own. In principle the Java EE certification list provides you with a range of different products which at least comply to the so called Java EE TCK. The TCK is heavily discussed and it is safe to assume that it does not cover every single line of all contained specifications completely. But every certified Java EE server should basically be ready to execute a Java EE application. The write once - run everywhere principle can be achieved (at least to a certain extend).
Bottom line of your decision is: Avoid (vendor) specific features and build your new application on an open industry standard which provides flexibility and choice between different products and vendors.
Beside this you gain additional value by having the flexibility to choose from a broad range of companies and developers offering skills and services in Java EE technologies.

WildFly 8 and GlassFish 4 are equal from a Java EE 7 Perspective
With the announcement of WildFly 8 CR1 it passes the Java EE 7 TCK. Even if the official paperwork obviously haven't been completely processed it looks like the 8 final will officially be certified. At least with regards to the Java EE 7 technologies both servers offer the same. There is and always has been different additional features surrounding the core technology stack but I haven't done a complete feature comparison of them and I honestly have no intend of doing it.
If you plan on doing a greenfield development come up with your own decision making process and weight those additional metrics in. You're already and Oracle or Red Hat customer? Or using additional infrastructural components which work best with the one or the other? In my experience you also need to weight in a couple of others (from my own experience we are talking about >=30) and rank them accordingly.

Migrate from GlassFish 2.x, 3.x to 4.0?
The most commonly asked question these days. What should I do with the applications which are already running on GlassFish 2.x or 3.x? It probably is the hardest one. I would need to know a bit more from you to answer it.

Oracle/GlassFish Customer/Shop and not changing anything?
Are you already using the Oracle GlassFish Server (commercially supported version) or are you using the Open Source version? Do you plan on extending the application or use newly introduced Java EE 7 features? If you are hooked up with Oracle or the commercial version already and you are NOT planning on making any changes you basically don't have to worry about migrating at all. Existing Oracle GlassFish Server 2.1.x and 3.1.x commercial customers will continue to be supported according to the Oracle Lifetime Support Policy (PDF). I basically don't recommend to migrate at all if you're in that kind of setting. The extended support for both servers ends in January 2017 (GFv2) respectively March 2019 (GFv3).

Oracle/GlassFish Customer/Shop and willing to use new Java EE 7 features early?
So you are an Oracle Customer and you are keen to use latest technology early? Or you need to heavily modify your applications?
You basically have three options: Stick with the GlassFish 4 OSS Version (without support contract) or move to the WebLogic 12c (12.1.4) which will most likely have full EE 7 support or do this step by step by first moving to GF 4 and then to WebLogic 12.1.4 later.
Directly switching to GlassFish and planning to go on with WebLogic in production later carries the risk of using different application servers in development and production. You need to value this in and handle it accordingly.
To completely reduce the risk I would recommend to wait for at least the WebLogic 12.1.3 which is expected to have a first set of new Java EE 7 specifications and will hopefully available sometime during the first half of CY2014.
If you don't run a mission critical application and you don't need a support contract I recommend to migrate to GlassFish 4.0 in order to facilitate the already available infrastructure and skills and contracts. To me there is no point in hastily switching vendors. Be prepared for ending support contracts and plan on evaluating your decisions about the right Open Source Application Server then.

Not really and Oracle Customer/Shop, not changing anything no interest in new EE 7 features?
Don't migrate at all until your requirements change. You might start evaluating your next Java EE 7 server product soon. But as of today there aren't many certified alternatives available.

Not really and Oracle Customer/Shop, changing requirements, will to use new EE 7 features?
Might be time to revisit your IT landscape this year. It seems as if you've decided to go with GlassFish at some point. You might have to revisit your former decision and evaluate what to do. To make a well grounded decision about your next Java EE server you are too early. The certification matrix for EE 7 servers is mostly empty. Wait for more alternatives to come up. I expect this to take most of CY2014.
If you have the need for new EE 7 features as of today and you need to be able to buy commercial support in the future but don't need it right here and now the only alternative you have is WildFly 8.

What does the future hold for GlassFish 4?
I wish I could tell you. I guess I made my points in the earlier posting. Oracle needs GlassFish to stick around as Java EE Reference Implementation and given the number of commonly used components in both WebLogic and GlassFish it will always be there. And it is safe to assume that the Java EE specifications will always be the latest and greatest in GlassFish. But the Java EE ecosystem lead to a bunch of vendor specific extensions and features which are not really covered by any specification. Those are commodity  to all of us (mostly clustering, admin Features, embedded server) and we don't want to miss them in many cases. Further on the patch frequency and grade of community participation will be crucial factors for the successful spread of GlassFish among projects and developers.

I’m speaking at OUGN Spring Conference 3rd-5th of April 2014, Oslo-Kiel

I'm pretty proud to announce, that I will be speaking at the annual OUGN spring seminar again. After my first time last year I was once again invited to speak by the Norwegian Oracle User Group (OUGN).

Last year's trip was sheer pleasure and I am very much looking forward to exciting talks and the unique conference experience that cruise ship provides. You can look at my photo sets on Google+ (Day 1, Day 2, Day 3 and Day 4) or at the complete trip report from last year to get a good impression about it.
This year, I'll give two presentations in both Java and the Middleware space this year.


Friday April 4, 2014 09:30 - 10:15 Congress 1+2 (Color Magic)
WebLogic 101 (P166)
This is a basic introduction into Java EE 6 and WebLogic 12c for everybody interested in the basics. Giving a brief overview about the needed skills and providing a guide to everything you need to know for getting started. No matter if you're a DBA or developer.

Thursday April 3, 2014 16:00 - 16:45 Congress 3 (Color Magic)
Developer Security Awareness (P163)
All the common attacks we've known about for a very long time are still out there, and people still regularly make mistakes regarding them. This is an engaging session about Java EE technology, people, and processes and how they best work together to build a suitable secure system. Derived from practice for use with everyday development, such a system can make the Java EE space a little more secure.

Additionally there will be plenty of time to talk and exchange experiences. Thanks for the invitation! I am very much looking forward seeing you there! Don't forget to have a look at the complete schedule and register if you haven't done so!

Another year is nearly over…

... and it is time to sit back and relax a bit. It has been exhausting for me on many levels and I tried not to leave any opportunity slip through. It is time to say thanks. I'm thankful for the many people seeing me sessions on conferences around the world. Thankful for the readers on this blog, for the feedback I receive on Twitter or even in person. Thankful for a steadily growing and strong Java community and even thankful for Oracle taking the steward job serious and not having burnt too many bridges this year.

There are plenty of things upcoming next year. All starts with the IOUC meeting in January, a great Jfokus conference in Stockholm in February, the JavaLand conference in March followed by the OUGN Vårseminar and the newly created DevNation conference in April. There are plenty of opportunities to meet and talk. I'm looking forward to this new year. And some silent days.
Wishing you a prosperous and happy new year


“We will open the book.
Its pages are blank.
We are going to put words on them ourselves.
The book is called Opportunity
and its first chapter is New Year's Day.”
― Edith Lovejoy Pierce

See me at DevNation, 13 – 17 April 2014, San Francisco, CA

I'm pretty proud to announce that I'll be speaking at the new open source, polyglot conference for application developers and maintainers DevNation 2014. It will be co-located with Red Hat Summit and will offer sessions, labs, and panels geared for those who build with open source.


As of today the official call for papers starts. Now it's on you to join the early announced speakers among myself, Mike Milinkovich (Eclipse), Chris Aniszczyk (Twitter), Arun Gupta (Red Hat).


While there will not be formal tracks you can send in proposals among the following topics that will likely fit into overall vibe including:

  • Enterprise Application Development (e.g. concurrent, multi-user applications with data stores, security, transactions, etc)
  • Front-end Development (e.g. display technologies, client-side scripting and layout, templating engines)
  • Mobile Development (e.g. Android, iOS, Cordova, HTML5 for mobile)
  • Big Data (e.g. RDBMS and NoSQL, persistent storage and associated computational problems with large data stores)
  • Application Integration (Service-Oriented Architecture)
  • DevOps and Continuous Delivery (e.g. build and deployment environments, administration and management)
  • Performance and Tuning (e.g. Analysis and techniques to get the best out of your applications)
  • Platform Development (ie. C++ and *nix applications)
  • Cool Stuff (Any helpful bits you'd love to share with your peers)

You can hook up with this awesome new conference by joining the twitter discussion @DevNationConf or tweet with the official #DevNation14 tag and don't forget to check back with the conference website frequently for new announcements.

Open registration begins in January 2014. Come to hack, come to learn. Join the Nation.

Project Avatar – What’s in it for Java EE 8?

With Java EE 7 out the door since a while it is already time to start planning for the next revision of the platform which will most likely be called Java EE 8. Oracle set up a community survey with which they would like to get input from the community on the relative importance of some of the features they intend to add. First of all this should encourage the interested reader to participate and take the survey. One particular point in it is all about support for HTML 5 based, dynamic applications. While WebSocket and JSON Processing already made it into Java EE 7 there is another feature particularly in GlassFish and WebLogic (via Jersey) at the moment which has some potential to be standardized. The Server Sent Events (SSE). It already is part of the HTML5 spec and would be a very good candidate for standardization. But Oracle is thinking even further and is asking if there would be enough support and interest to actually standardize the use of JavaScript on  Java EE servers. When this kind of question started to appear at JavaOne 2012 it was basically referred to as Node.jar on Nashorn. Since this September we know the real name: Project Avatar.

Avatar At A Glance
Project Avatar provides a JavaScript services layer zeroed in on supporting REST, WebSockets and Server-Sent Events, and a rich client side framework that assumes very minor JavaScript knowledge. The services side is focused on building data services using JavaScript, while the optional client side is entirely focused on supporting HTML5 and TSA (Thin Server Architecture).


Project Avatar (Source: avatar.java.net)

Thin Server Architecture
With the introduction of HTML5, CSS3 and fast JavaScript engines, modern browsers have become a powerful platform. In the advent of the so called single-page application (SPA), also known as single-page interface (SPI) the design of modern user interfaces shifted away from server side generation to web applications or web sites that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application. An SPA moves logic from the server to the client. This results in the role of the web server evolving into a pure data API or web service. This architectural approach has been coined "Thin Server Architecture" to indicate that complexity moved from the server to the client while reducing overall system complexity.

What is really in Avatar?
But Avatar is far more than just a TSA approach. It basically consists of three parts. The foundation is build by the upcoming Java 8 and its included JavaScript implementation called Nashorn. On top of it is the Avatar Runtime including an additional compiler layer and a Servlet API based server. Those abstractions  enable it to be hosted on various runtimes. Avatar applications are comprised of either client side ‘views’, server side ‘services’ or both. Importantly, there is no inherent coupling between them which enables views to communicate with existing services and for services to be consumed by any type of client. An application ‘archive’ is deployed on the server and is compiled to generate JavaScript tailored to the application. Generated JavaScript for views handles data-binding with the DOM/UI as well as data-management to remote services and local storage. The Avatar archives are somewhat similar to Java EE web-archives. They consist of a WEB-INF folder, an avatar.properties file in the root and either a views directory and/or a service directory. Both file-system directories or .zip (.war) files are supported by Avatar.

All that is left on the Server - Services
A service extends either a REST, WebSocket or Push (SSE) abstraction and it's life-cycle is completely handled by the framework. Service implementations can leverage built-in Node modules as well as most third-party modules. Thanks to Nashorn's support for direct invocation of Java code you can also use most Java libraries directly.

The Client Side - Views
A view is the HTML required by the browser. It also contains custom 'data-' HTML extensions and simple JavaScript models. Those views get translated by a (server-side) compiler before sending the complete SPA HTML file including the custom generated JavaScript to the browser.

Putting it all together. A Simple Example.
Oracle provides a decent set of examples and documentation for Avatar which basically is enough to get you started. First thing to try it out yourself is a JDK 8 Early Access Build for your OS. At the time of writing I tried it with the latest Developer Preview b118. After installing you need to get the latest GlassFish Open Source Edition 4.0 server and unzip it into a suitable location. Make sure it runs with the installed JDK 8 by either putting <jdk8>/bin to your PATH environment variable or adding the following entry to the <gf4>/glassfish/config asenv.bat/conf

set AS_JAVA=<jdk8>

Now go ahead to download latest avatar-1.0-ea.zip and expand it to the <gf4>/glassfish/ directory. After that you need to set a AVATAR_HOME environment variable and point it to the <gf4> install directory. And make sure to add %AVATAR_HOME%glassfishbin to your PATH environment variable.
If all of that is done you can switch to your workspace folder and issue the following command to have Avatar creating a simple example app for you:

avatar new --example=hello

It creates a basic "hello" application which only consists of a view. It is a good place to start exploring and you can directly start your Glassfish instance afterwards and deploy the application as you would with every typical Java EE application:


asadmin start-domain


asadmin deploy hello


The "hello-example" app.
Pointing your browser to http://localhost:8080/hello will display the application. You can start editing the view located at <workspace>/hello/view/src/hello.html directly. While the server is running Avatar takes care of re-compiling it directly for the next request. This ensures a rapid development. This behavior is controlled by the "debug=true" property in the avatar.properties file and can be altered for productive systems. Further on, setting it to false causes all .js and .css files to be minimized before delivery.
At least if you first download and add the required YUI Compressor (jar download) to Avatar first. Due to license restrictions it hasn't been bundled. Simply put it into <gf4>/glassfish/modules/avatar-ext/lib. You might need to create that directory first.

Beside this very simple example without any service at all there are more complex ones available with the distribution at %AVATAR_HOME%/Project-Avatar-examples/. For convenience reasons there is a complete examples.ear available which can be directly deployed and tested. To access the samples simply prefix the example name with "demo-". So the "rest" example can be accessed via http://localhost:8080/demo-rest/.
TodoMVC - Example App with Avatar
You have to look out for different features to be showcased in the different examples. If you want to know how Avatar handles persistence you can exactly look into the rest example which uses a FileDataProvider to save the items. Another interesting example is the TodoMVC based app (http://localhost:8080/demo-todo/). It showcases a more complex view which also has been styled.

What is next?
As of today nobody knows what is going to happen with Avatar. The community feedback hasn't been tremendously loud or excited in general. I guess the reason for it is that nobody really knows what to do with it. The biggest drawback as of today is, that it only runs with GlassFish which will further limit adoption and community interest. Given the fact, that SSE isn't part of the Java EE specification it might make it even more difficult to port it to other app-server. Even if the license (GPL2 with Classpath Exception) should allow it. Back to the initial survey and the thought about specifying a server side JavaScript integration with Java EE, you know at least have a brief idea about what Oracle is talking if they are talking about Avatar. Go ahead and take that survey and tell them what you are thinking about having that kind of stuff in Java EE.

Meta: this post is part of the Java Advent Calendar and is licensed under the Creative Commons 3.0 Attribution license. If you like it, please spread the word by sharing, tweeting, FB, G+ and so on!

Project Avatar – What’s in it for Java EE 8?

With Java EE 7 out the door since a while it is already time to start planning for the next revision of the platform which will most likely be called Java EE 8. Oracle set up a community survey with which they would like to get input from the community on the relative importance of some of the features they intend to add. First of all this should encourage the interested reader to participate and take the survey. One particular point in it is all about support for HTML 5 based, dynamic applications. While WebSocket and JSON Processing already made it into Java EE 7 there is another feature particularly in GlassFish and WebLogic (via Jersey) at the moment which has some potential to be standardized. The Server Sent Events (SSE). It already is part of the HTML5 spec and would be a very good candidate for standardization. But Oracle is thinking even further and is asking if there would be enough support and interest to actually standardize the use of JavaScript on  Java EE servers. When this kind of question started to appear at JavaOne 2012 it was basically referred to as Node.jar on Nashorn. Since this September we know the real name: Project Avatar.

Avatar At A Glance
Project Avatar provides a JavaScript services layer zeroed in on supporting REST, WebSockets and Server-Sent Events, and a rich client side framework that assumes very minor JavaScript knowledge. The services side is focused on building data services using JavaScript, while the optional client side is entirely focused on supporting HTML5 and TSA (Thin Server Architecture).


Project Avatar (Source: avatar.java.net)

Thin Server Architecture
With the introduction of HTML5, CSS3 and fast JavaScript engines, modern browsers have become a powerful platform. In the advent of the so called single-page application (SPA), also known as single-page interface (SPI) the design of modern user interfaces shifted away from server side generation to web applications or web sites that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application. An SPA moves logic from the server to the client. This results in the role of the web server evolving into a pure data API or web service. This architectural approach has been coined "Thin Server Architecture" to indicate that complexity moved from the server to the client while reducing overall system complexity.

What is really in Avatar?
But Avatar is far more than just a TSA approach. It basically consists of three parts. The foundation is build by the upcoming Java 8 and its included JavaScript implementation called Nashorn. On top of it is the Avatar Runtime including an additional compiler layer and a Servlet API based server. Those abstractions  enable it to be hosted on various runtimes. Avatar applications are comprised of either client side ‘views’, server side ‘services’ or both. Importantly, there is no inherent coupling between them which enables views to communicate with existing services and for services to be consumed by any type of client. An application ‘archive’ is deployed on the server and is compiled to generate JavaScript tailored to the application. Generated JavaScript for views handles data-binding with the DOM/UI as well as data-management to remote services and local storage. The Avatar archives are somewhat similar to Java EE web-archives. They consist of a WEB-INF folder, an avatar.properties file in the root and either a views directory and/or a service directory. Both file-system directories or .zip (.war) files are supported by Avatar.

All that is left on the Server - Services
A service extends either a REST, WebSocket or Push (SSE) abstraction and it's life-cycle is completely handled by the framework. Service implementations can leverage built-in Node modules as well as most third-party modules. Thanks to Nashorn's support for direct invocation of Java code you can also use most Java libraries directly.

The Client Side - Views
A view is the HTML required by the browser. It also contains custom 'data-' HTML extensions and simple JavaScript models. Those views get translated by a (server-side) compiler before sending the complete SPA HTML file including the custom generated JavaScript to the browser.

Putting it all together. A Simple Example.
Oracle provides a decent set of examples and documentation for Avatar which basically is enough to get you started. First thing to try it out yourself is a JDK 8 Early Access Build for your OS. At the time of writing I tried it with the latest Developer Preview b118. After installing you need to get the latest GlassFish Open Source Edition 4.0 server and unzip it into a suitable location. Make sure it runs with the installed JDK 8 by either putting <jdk8>/bin to your PATH environment variable or adding the following entry to the <gf4>/glassfish/config asenv.bat/conf

set AS_JAVA=<jdk8>

Now go ahead to download latest avatar-1.0-ea.zip and expand it to the <gf4>/glassfish/ directory. After that you need to set a AVATAR_HOME environment variable and point it to the <gf4> install directory. And make sure to add %AVATAR_HOME%glassfishbin to your PATH environment variable.
If all of that is done you can switch to your workspace folder and issue the following command to have Avatar creating a simple example app for you:

avatar new --example=hello

It creates a basic "hello" application which only consists of a view. It is a good place to start exploring and you can directly start your Glassfish instance afterwards and deploy the application as you would with every typical Java EE application:


asadmin start-domain


asadmin deploy hello


The "hello-example" app.
Pointing your browser to http://localhost:8080/hello will display the application. You can start editing the view located at <workspace>/hello/view/src/hello.html directly. While the server is running Avatar takes care of re-compiling it directly for the next request. This ensures a rapid development. This behavior is controlled by the "debug=true" property in the avatar.properties file and can be altered for productive systems. Further on, setting it to false causes all .js and .css files to be minimized before delivery.
At least if you first download and add the required YUI Compressor (jar download) to Avatar first. Due to license restrictions it hasn't been bundled. Simply put it into <gf4>/glassfish/modules/avatar-ext/lib. You might need to create that directory first.

Beside this very simple example without any service at all there are more complex ones available with the distribution at %AVATAR_HOME%/Project-Avatar-examples/. For convenience reasons there is a complete examples.ear available which can be directly deployed and tested. To access the samples simply prefix the example name with "demo-". So the "rest" example can be accessed via http://localhost:8080/demo-rest/.
TodoMVC - Example App with Avatar
You have to look out for different features to be showcased in the different examples. If you want to know how Avatar handles persistence you can exactly look into the rest example which uses a FileDataProvider to save the items. Another interesting example is the TodoMVC based app (http://localhost:8080/demo-todo/). It showcases a more complex view which also has been styled.

What is next?
As of today nobody knows what is going to happen with Avatar. The community feedback hasn't been tremendously loud or excited in general. I guess the reason for it is that nobody really knows what to do with it. The biggest drawback as of today is, that it only runs with GlassFish which will further limit adoption and community interest. Given the fact, that SSE isn't part of the Java EE specification it might make it even more difficult to port it to other app-server. Even if the license (GPL2 with Classpath Exception) should allow it. Back to the initial survey and the thought about specifying a server side JavaScript integration with Java EE, you know at least have a brief idea about what Oracle is talking if they are talking about Avatar. Go ahead and take that survey and tell them what you are thinking about having that kind of stuff in Java EE.

Meta: this post is part of the Java Advent Calendar and is licensed under the Creative Commons 3.0 Attribution license. If you like it, please spread the word by sharing, tweeting, FB, G+ and so on!

My vJUG Session: Don’t Be That Guy! Developer Security Awareness

I've been invited to talk at the vJUG which is the newest JUG around. A virtual JUG reaching out to interested Java Developers over all time zones and locations. The  aim is to get the greatest minds and speakers of the Java industry giving talks and presentations for this community, in the form of webinars and JUG session streaming from JUG f2f meetups.

"Don't be that guy! Developer Security Awareness" by Markus Eisele
Was a session already scheduled for JavaOne this year. Due to scheduling conflicts I actually had to cancel it and I was pretty excited to finally be able to deliver it to the many who signed up for the session in SF. With 174 registered attendees I count this as a success.

The session was given via Google Hangout (Thanks Google!) and recorded to Youtube for you to re-watch.

The slides are on speakerdeck.com:
Thanks everybody for attending! It was a pleasure!