Thursday, September 27, 2012

Day 0: Oracle OpenWorld and JavaOne


The special days in the year are finally there. After some excitement during the latest early access and internal preview actions I was involved it is finally time to fly to San Francisco and see all that stuff being announced at the annual Oracle conferences OpenWorld and JavaOne. This post kicks of my week in the states.

Traveling
My first time on KLM. Being a loyal Lufthansa customer since some time I was forced to switch carrier because they simply beat the Lufthansa price tack significantly. No A380 for me this time. Instead I had to fly the airplane of my dreams: a Boeing 747-400. When I was a little kid visiting FRA for the first time it was the biggest airplane and I dreamed of flying with it. Honestly some time has passed by since then and it is an old airplane today. Anyway it was a nice experience and the KLM crew did a good job during the flight in serving the customers. So, I was positively surprised. All-in-all it was a long trip and I was happy to fall into the hotel bed after 38h.

ACED Briefing
Some comments on twitter today about why I am that early. JavaOne starts Sunday with the keynotes. Part of the annual experience is the ACE Director Briefing at Oracle Headquarters. We have a packed schedule and get a gist of OpenWorld in two days front-up. The negative side here is, that we simply aren't allowed to blog about the details until they officially show up during OpenWorld. The schedule today starts at 08:30 with an update on the Oracle Development Tools; followed by an update on the Oracle Database. After that it was Middleware and Cloud time; passing by IdM and finally meeting Thomas Kurian and Steve Miranda. Wim Coekaerts closed the day with an update on Virtualization and Linux. It is annoying that we are forced to be silent. But also completely fair. All Oracle is asking for are some 30h to keep the silence. And this is doable even for the most vocal ACEs.
Talking to the fellow ACEs we realize, that we're meeting once a year and keep getting older. But this doesn't stop us from having fun and doing some networking.

The OTN "Thank-you"
I probably do this every year. But I can't help myself but send this big "Thank-you" out to Lillian, Vikki and their team. Without you and your support we wouldn't be here and we probably wouldn't be able to make the right connections to help or give feedback! It's a pleasure to contribute and an honor to be an ACED. Thanks for all your efforts for bringing the right PMs to the briefing and for organizing some great OpenWorld days!

Saturday, September 22, 2012

Oracle and Maven - a love story out of the ordinary.


It is weekend. Not my typical time for publishing blog-posts. I tend to write them but publishing is done during the week. This might be a different kind of post because I read the Javalobby post about "Oracle and Maven" this morning and I was wondering if that is actually what everybody thinks out there.

Where is Maven within Oracle?
Short answer: Everywhere! Need a short list? Here we go:
GlassFish is build with Maven (compare FullBuildInstructions). Until v3 it was 2.2.1 but the tunk now is on 3.0.3. There is still some Ant around but most of the stuff has been using Maven since a long time.
You have a sufficient support with plugins. The GlassFish Maven plugin, the GlassFish Embedded Plugin and last but not least the GlassFish support with Maven's Cargo Plugin. On top of that you have remote and local container adapters for Arquillian here.

WebLogic is a different kind of story. The server and the distribution itself is still build with Ant as far as I know. But there also is a growing Maven support over here. We have support from a WebLogic Maven Plugin since 10.3.5 and with the latest 12c the features grew a lot. Weird here is, that the plugins don't reside in central. You have to install them locally and make them available for every developer through your own proxy. Even the plugin-group registration has to be done manually. Not very convenient to use, but after all: We have it. Further on you can distribute complete weblogic installations via the plugin based on the zip installer.
Maven has first class support with NetBeans and I find it quite handy at all. If you find a complaint here, let me know. You can use the build in version (3.0.3) which is nearly the latest but nobody stops you from using your custom version.
Oracle's brand new and upcoming offering, the Java Cloud Service has a decent Maven support. And so are many many other projects and reference implementations.

To me this doesn't sound like someone is having "a strategy for avoiding Maven" (quote from the Javalobby-Post). In fact it feels like the process I have seen a lot with other projects and technologies. Adoption. Obviously not early adoption but tell me about the few products doing premature stuff at a decent risk. That doesn't sounds like a way a very successful company would go.

What could be improved?
I agree on the annoyance with the javaee*-api artifacts in repo1.maven.org. That is completely uncomprehending and I don't have a clue why that is still the fact. I hope that this post will put this back on any of the priority lists. I for myself am using the Java EE BOM from JBoss here. Another idea is to pull in the glassfish-embedded-all:3.1.2.2 dependency which also works but obviously offers more than you probably want to have. Another annoyance is the fact, that EclipseLink as the JPA reference implementation isn't on central. You still have to use the Eclipse Maven repo for that. That complicates stuff unnecessary. Every complaint to change that wasn't successful. But I still have hope. But it might be, that the reason for that is that EclipseLink itself still is using Ant to build. Even if there are some maven dependencies and plugins available. Even if they are not officially supported. (e.g. Maven plugin for Eclipselink static weaving)

What is wrong with the Javalobby post?
Different things. First of all I don't like the tone. And I don't like if somebody doesn't do his homework and simply states: " ... the Oracle artifacts are ..." (quote from the Javalobby-Post). Generalization isn't helpful because nobody knows what to change. And with respect to this I understand Oracle (if this is a valid generalization on my side) that nobody actually feels responsible for changing anything. So, if you have things that sucks: Get them out and tell the world. But don't blame a brand for "doing things wrong". There are people responsible for that. Find out who they are and give honest feedback.
But beside this, the content is wrong. At least partly. I looked around and searched maven central. I did some spot tests (GlassFish, Mojarra, Metro) if they have souces and the javadoc jars are available. They have at least the sources. Partly javadoc. There isn't a complete coverage on every artifact. And especially those ones developers are looking for (e.g. jsf-api) don't provide javadocs. There is room for improvement and I hope that someone from the middleware group is reading this and starts getting the priorities right here. Haven complete dependencies in central is developer productivity. Nothing more and nothing less. And this is something the stewards of Java EE should take care of.

Wednesday, September 19, 2012

Running RichFaces on WebLogic 12c


I initially thought I could write this post months back already. But I ended up being overwhelmed by different things. One among them was, that it wasn't able to simply fire up the RichFaces showcase like I did it for the 4.0 release. With all the JMS magic and the different provider checks in the showcase this has become some kind of a challenge to simply build and deploy it.
Anyway, I was willing to give this a try and here we go. If you want to get started with any of the JBoss technologies it is a good idea to check with the JBoss Developer Framework first. That is a nice collection of different examples and quickstarts to get you started on Java EE and it's technologies. One of them is the RichFaces-Validation example which demonstrates how to use JSF 2.0, RichFaces 4.2, CDI 1.0, JPA 2.0 and Bean Validation 1.0 together.

The Example
The example consists of a Member entity which has some JSR-303 (Bean Validation) constraints on it. Usually those are checked in several places, beginning with the Database, on to the persistence layer and finally the view layer in close interaction with the client. Even if this quickguide doesn't contain a persistence layer it starts with the Enity which reflects the real life situation quite good. The application contains a view layer written using JSF and RichFaces and includes an AJAX wizard for new member registration. A newly registered member needs to provide a couple of information before he is actually "registered". This includes e-mail a name and his phone number.

Getting Started
I'm not going to repeat what the excellent and detailed quickstart is already showing you. So, if you want to run this on JBoss AS7 .. go there. We're starting with a blank Maven web-project. And the best and easiest way to do this is to fire up NetBeans 7.2 and create one. Lets name it "richwls-web". Open your pom.xml and start changing some stuff there. First remove the endorsed stuff there. We don't need it. Next is to add a little bit of dependencyManagement:
 <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.bom</groupId>
                <artifactId>jboss-javaee-6.0-with-tools</artifactId>
                <version>1.0.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            
            <dependency>
                <groupId>org.richfaces</groupId>
                <artifactId>richfaces-bom</artifactId>
                <version>4.2.0.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>
This adds the Bill of Materials (BOM) for both Java EE 6 and RichFaces to your project. A BOM specifies the versions of a "stack" (or a collection) of artifacts. You find it with anything from the RedHat guys and it is considered "best practice" to have one. At the end this makes your life easier because it manages versions and dependencies for you.
On to the lengthy list of true dependencies:
<!-- Import the CDI API -->
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        
        <!-- Import the JPA API -->
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0.2</version>
            <scope>provided</scope>
        </dependency>
        
        <!-- JSR-303 (Bean Validation) Implementation -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.3.0.Final</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <!-- Import the JSF API -->
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        
        <!-- Import RichFaces runtime dependencies - these will be included
        as libraries in the WAR -->
        <dependency>
            <groupId>org.richfaces.ui</groupId>
            <artifactId>richfaces-components-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>org.richfaces.core</groupId>
            <artifactId>richfaces-core-impl</artifactId>
        </dependency>
        
Except the RichFaces dependencies all others are provided by the runtime. In this case it will be GlassFish 3.1.2.2. In case you haven't defined it elsewhere (settings.xml) you should also add the JBoss repository to your build section:
 <repository>
                    <id>jboss-public-repository-group</id>
                    <name>JBoss Public Maven Repository Group</name>
                    <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
                </repository>
Copy the contents of the richfaces-validation directory of the source-zip or check it out from github. Be a little bit careful and don't mess up with the pom.xml we created ;) Build it and get that stuff deployed.

Issues
First thing you are greeted with is a nice little weld message:
WELD-000054 Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans [...] Producer Method [Logger] with qualifiers 
We obviously have an issue here and need to declare the Logger field as transient.
@Inject
private transient Logger logger;
Don't know why this works on AS7 but might be I find out someday :) Next iteration: Change it, build, deploy.
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet;
That doesn't look better. Fire up the WLS CAT at http://localhost:7001/wls-cat/ and try to find out about it.
Seems as if Oracle is using Google magic inside the server. Ok, fine. We have no way to deploy RichFaces as a standalone war on WebLogic because we need to resolve some classloading issues here. And the recommended way is to add a so-called Filtering Classloader. You do this by adding a weblogic-application.xml to your ear. Yeah: Lets repackage everything and put the war into an empty ear and add the magic to the weblogic-application.xml:
 <prefer-application-packages>
        <package-name>com.google.common.*</package-name>
    </prefer-application-packages>
Done? Another deployment and you finally see your application. Basically RichFaces run on WebLogic but you have to package it into an ear and turn the classloader around for the com.google.common.* classes. That is way easier with PrimeFaces but ... anyway, there are reasons why I tried this. One is, that I do like the idea of being able to trigger the Bean Validation on the client side. If you take a look at the example you see, that the <rich:validator event="blur" /> adds client side validation for both bean validation constraints and standard jsf validators to the client. Without having to mess around with anything in JavaScript or duplicate logic. Great! Thanks!

New Article in German iX Magazin: Java Batch


Another article for my German readers hit the road today. I was looking into Java Batch. All about the basic concepts and different approaches to make this more transparent to us Java developers. Have fun reading it!

Serial Offender
Many Java programmers think of batch processing as a relic of bygone days. The associated tasks, however, are still valid and seep slowly out of a mainframe area in the Java EE world. Standard and frameworks for this are still rare. An inventory.

This is a German article and you can either grab the latest issue online or buy it at your favorite kiosk.

Find some other articles of mine by searching this blog for posts labeled "article". Any feedback appreciated!

Tuesday, September 18, 2012

Review: "Java EE 6 Pocket Guide" by Arun Gupta


This is a review I am very pleased to write. My friend Arun published the Java EE 6 pocket guide and it will be at your hands as early as you can order. I knew about the book quite early, because I had the pleasure to review it and I am thankful for the chance to contribute a little to it! The Kindle edition is already available and the printed books should be available until JavaOne. There is a good chance to have Arun sign it, if you bump into him there!

Abstract
The Java Enterprise Edition 6 platform provides capabilities that make it easier for Java programmers to develop and deploy enterprise and Web applications. This handy guide provides an overview of the main technologies in the Java EE 6 platform, including extensive easy-to-understand code samples that demonstrate many improvements. Whether you're familiar with Java EE 5 or a Java programmer approaching the enterprise edition for the first time, this book will quickly get you up to speed on Java EE 6. Discover how Java EE 6 provides a simplified developer experience and improves on the developer productivity features introduced in Java EE 5. Delve into Java EE 6 profiles, including a comprehensive profile for lightweight, standards-based modern web applications. Explore how the platform enables extensibility with open source libraries and frameworks. Learn how specifications such as Contexts & Dependency Injection, Java API for RESTful Services, and Servlets 3 make the platform more powerful.

Book: "Java EE 6 Pocket Guide"
Language : English
Paperback: 204 pages
Release Date : September 2012
ISBN-10: 144933668X
ISBN-13: 978-1449336684

The Author
Arun (@arungupta) is the Java EE evangelist at Oracle. He has over 15 years of experience in the software industry working in the Java platform and several web-related technologies. In his current role, he works to create and foster the community around Java EE and GlassFish. He has been with the Java EE team since its inception and contributed to all releases. Arun has extensive world wide speaking experience on myriad of topics and loves to engage with the community, customers, partners, and Java User Groups everywhere to spread the goodness of Java. He is running a well know blog named "Miles to go..."

The Content
204 pages is a good size for a pocket guide. It covers the basics you need to know of Java EE 6 and gives good examples of all relevant parts. Chapter 1  introduces you to the Java Enterprise Edition in general. Chapter 2 follows with a brief introduction to Managed Beans and their overall life-cycle. Chapter 3 dives into Servlets and all relevant parts. Chapter 4 introduces the Java Persistence API beginning with Entities and the surrounding happenings. Chapter 5 dedicates content around the Enterprise JavaBeans specification. Thins includes Stateful, Stateless, Singleton and Message-Driven up to the Embeddable API and the EJBLite specification. Chapter 6 is about Contexts and Dependency Injection including the portable extensions. The Chapter 7 covers JavaServer Faces very briefly and introduces you to the main concepts. Chapters 8 and 9 are about SOAP-Based Web Services and RESTful Web Services with simple and understandable examples. Chapter 10 covers the Java Message Service with a message send example. The book closes with  Chapter 11 about Bean Validation and how it integrates with JPA and JSF.

Writing and Style
This is a pocket guide which is comprehensively written. I could follow all examples and it was a good read overall. No complicated constructs and clear writing. Walking from chapter to chapter works, but it isn't designed like that. It is more like a reference book to look up the most important topics in Java EE 6 at one point. It isn't watered-down by complex examples and sticks to the most important characteristics of the covered specifications. If you ever have seen one of Arun's presentations or tutorials you know that he is good in explaining things and this style found the way into the guide.


Conclusion and recommendation
I'm obviously not neutral here :) GO GET IT! It is the only book you probably will need about Java EE 6! It is comprehensive, wonderfully written and covers everything you need in your daily work. It is not a complete reference but provides a great shortcut to the things you need to know. To me it is a good beginners guide and also works as a companion for advanced users. Get it while it's hot! Thanks Arun for sharing your knowledge!

Thursday, September 13, 2012

JavaZone 2012 Trip Report


Being back home it is time to summarize my latest trip a bit. I was in Oslo, Norway for JavaZone, which is the biggest meeting place for software developers in Scandinavia, and one of Europe's most important conferences. JavaZone has been described as a high quality, independent conference - a leading forum for knowledge exchange for IT-professionals. Each year around 2,300 conference tickets are sold. This years JavaZone is the eleventh. They got most famous for their promotional videos you can find on a dedicated page on their website. All this is organized by javaBin which is a non-profit, independent organization. The purpose is to promote java skills among members, member firms and the market. javaBin is headquartered in Oslo, with subgroups in Stavanger, Bergen, Trondheim and the South Coast..
What did I do this far in the north? Good question. I was attending last years Jfokus and I was very surprised by the warm welcome and the overall atmosphere there. And I'm some kind of person who loves to be in northern areas. So it was only one more step to submit a talk after my friend Masoud Kalali pointed me to it. That should have been a combined talk. Unfortunately he fell sick and I had to take this on my own.

The Trip
Looking at cheep flights and accommodation I arrived noon on the day before the conference. The 2 hour direct flight is convenient and not too long. Best way from OSL to Oslo is to take the Flytoget which is the airport express. It is cheep compared with a taxi and comfortable to have power plugs and free wifi on board. After 30 minutes you arrive at Oslo S which is the central station. 5 minutes walk bring you to most of the venue hotels. Those mostly are around the Oslo Spektrum which is the venue where JavaZone is held. I stayed at the Thon Hotel Terminus. What should I say: It is ok for the few hours you stay there. Nothing (really nothing) compared to other hotels I have seen for the same price.

The City
Wonderful. It is big enough to not have a chance to do it in one day without any help of a local guide. Safe and mostly clean. You are at the waterfront in minutes (walking) and you can spend all the money you have because it simply is expensive. Norway itself is (25% VAT) but Oslo seems to be even more expensive. You can go everywhere with public transport and taxis. To me it felt a little bit like an american city. Don't know why, it might be the modern traffic signs or the sound of the ambulance. Nearly everybody is smiling around and even some rain didn't stop anybody from walking around. I enjoyed the feeling there. If you have the chance to walk around don't forget to visit the Oslo Opera House (Norwegian: Operahuset).  It is the largest cultural building constructed in Norway since Nidarosdomen was completed circa 1300. I love the architecture and the overall impression this makes.

The Venue
The Oslo Spektrum. Was build as part of the efforts to revitalize this part of the city. It should be a flexible venue with a lot of different functions.It was done by architects LPO architects AS. In collaboration with artist Guttorm Guttormsgaard and ceramist Søren Ubisch. The outside looks wonderful and the way it was used for JavaZone is good. The central auditorium was the exhibition area with lots of companies' booths and a javaBin booth in the overall center. Around that were the different rooms. Four in the lower level and three theater like rooms in the upper level. Especially the upper level rooms gave a university feeling which was very impressive and familiar from Jfokus. One room in the lower level, I believe it was room 3 had a split auditorium and the stage in the middle with the screen hanging above the head of the speaker. Lovely. Especially if you see someone like Tim Berglund speaking and acting in a space like that. A word about the catering. Four different kinds of food (Italian, Indian, Mexican and Sushi) from 10am until 6pm. Coffee all day long and on top of that water and soft drinks (at least around noon). And a beer duke which was spitting out beer if you held your registration QR code under his red nose. Very impressive lineup. No queues and longer waiting times. But it didn't work for me. I don't want a lunch before it is lunch-time and I want a cake in the afternoon and some kind of snacks in between do work a lot better for me than this 8h lunch package.  There is a complete album on Google+ with most of the pictures I took.

The Speaker Service
I was a first timer here. I know a couple of other conferences already and this doesn't made me feel bad about the one supporting email which came upfront giving information about the speaker dinner and a contact for further questions. But it was the only email that reached me and beside the very informal (but entertaining) speaker dinner this was my last contact with the organizers. The conferences I know a little better left another impression with me. I have seen a decent support for foreign speakers with someone being around and offering help and information. The javaBin guys have been at the booth the whole day for sure but they didn't made me feel like being a guest there. I was only one among all the other attendees. No, I'm not a diva. I don't need to be pampered the whole day. But I value a honest conversation and a friendly smile if I walk around alone the same place for the second time. Let's summarize it like this: There is always room for improvement.

Friends on the Road
Thank you Aslak! I had a great time chatting with you and Bartosz and it has been the best four beers in a row I had with some guys at a table talking about Java EE, Oracle, RedHat and kids, family and other stuff that matters since a year. I am truly looking forward meeting you again at JavaOne! Thanks Anton Arhipov for always being around for a nice chat! Thanks Dalibor! We had some good laughs about OpenJDK, Oracle and stuff that we better not disclose ;)
Beside that I meet some of the famous names of our business. Angelika Langer, Tim Berglund was around. I had the chance to introduce myself to James Ward and talk Kevlin Henney into a nice little interview.

PhotoZone
Talking about frustrations still leaves one thing open: My PhotoZone submissions. It's not that I need a new cam. But the Leica would have been nice. And generally I simply would have loved to see my pictures up on that PhotoZone screen. It seems as if it simply shouldn't be. So, for the records, these are three of the four submissions which didn't find their way to the contest.



The Talk
It was ok. 30 something attendees at the last slot of the last day is somehow more than I expected. And they were fair and interested listeners. I hope I was at least a little bit entertaining after two long and exhausting conference days. Here is the recording of the talk:

Java EE Security in practice with Java EE 6 and GlassFish from JavaZone on Vimeo.

Here are the slides:


Bottom Line
It was a nice trip. I reached a couple of people and had the chance to bring some more security into the Java EE world. Keep up the good work javaBin and I am looking forward to next years video trailers!
And it was a pleasure bringing Sparky to Norway with Arun having to cancel his trip with short notice!

Friday, September 7, 2012

The Heroes of Java: Stephen Colebourne


One more to go until my "Heroes of Java" series reaches the 20. No 19 is reserved for "Mr.Time and Date". With him also being nominated for this years annual JCP Awards as "Member of the Year" I finally had the chance to send him my little interview. Thanks for taking the time Stephen!

Stephen Colebourne
is a Member of Technical Staff at OpenGamma. He is widely known for his work in open source and his blog. He created Joda-Time which is now being further developed as JSR-310/ThreeTen. He contributes to debates on the future of Java, including proposals for the diamond operator for generics and FCM closures, both of which are close to the adopted changes in Java 7 and 8. Stephen is a frequent conference speaker, JavaOne Rock Star and Java Champion.

General Part
Who are you?
Stephen Colebourne. Java Champion, conference speaker, spec lead of JSR-310 dates and times, creator of the Joda Open Source projects, and occasional blogger of controversial topics.

Your offical job title at your company?
Member of Technical Staff

Do you care about it?
OpenGamma is an open source company. We are producing software for the finance industry, helping banks and hedge funds work out how risky their investments are. Being radically open in my work life means that
work is an extension of my other open source projects and I, or anyone else, can re-use the code I'm writing.

Do you speak foreign languages? Which ones?
I speak about 100 words of French, 10 words of German and 5 words of Dutch and Swedish. In other words I'm a typical person from the UK.

How long is your daily "bootstrap" process? (Coffee, news, email)
I'm cutting down on some of the waste here at the moment, but it still takes too long. Email is the biggest headache, when it frequently contains issues to be investigated.

Twitter
You have a twitter handle? Why?
@jodastephen. I reserved the handle as it was clearly a name-grab, and I didn't want anyone stealing my name. I was generally unconvinced until I spoke to someone who explained twitter as an advertising medium. From there I effectively use it to advertise my point of view.

Whom are you following in general?
A few people. I don't really "follow" people - its more a list of people that will get news and information to me quickly.

Do you have a personal "policy" for twitter?
I don't think twitter really is a social medium. Its just a broadcast/opinion one. Its most effective at disseminating news. The key thing is to keep your feed focussed - have a second feed if you have a second interest in life.

Does your company restricts or encourages you with your twitter ussage?
OpenGamma is happy to encourage twitter usage within sensible bounds.

Work
What's your daily development setup? (OS/IDE/VC/other Tools)
Eclipse on Windows, with SmartGit. I used to dislike git, but now I think its great. Trouble is that it took a week of deep-dive into git commands porting broken svn repositories to git for me to understand what the heck git was really all about. Its that usability that still worries me, but SmartGit makes it tolerable now day to day.

Which is the tool providing most productivity to your work?
I guess that is Eclipse, although git is helpful these days.

Your prefered way of interacting with co-workers?
I walk over and talk. My legs need stretching and its not far. If its non-urgent I'd send an email. I don't like IM.

What's your favorite way of managing your todo's?
Starred items in Gmail and a paper list of TODO items that I cross off. A simple online issue tracker can work, trying the GitHub one right now for JSR-310.

If you could make a wish for a job at your favorite company: What would that be?
Once upon a time I wanted to be paid just to write low-level library open source. Now I'm not so sure. Having customers and a focus is important to be able to see code being used.

Java
You're programming in Java. Why?
Its the world's enterprise language of choice. Being in the mainstream makes sense to me.

What's least fun with Java?
Almost everything! No seriously, Java is a poor language at this point compared to other languages out there. It is unnecessarily verbose in many places and hasn't tackled the real issues developers face, including null pointers, type conversion, properties and the most basic operator overloading.

If you could change one thing with Java, what would that be?
In terms of the pain, duplicated code and general waste in Java developers lives, properties are by far the most important feature missing. They should have been added in preference to generics and in preference to lambdas.

What's your personal favorite in dynamic languages?
If I had to use one, it would be Groovy, although I really don't have a need to do so. Basic static typing is far too useful to throw away. The problem is some developers in today's "more, more, more" society think that more static typing is helpful, when most of the time it simply results in humans trying to second guess compilers. By contrast, throwing static typing away for a dynamic language is giving up on a tool that stops many, many simple errors. Why would I want to give up on that? The most interesting languages have static typing but feel dynamic, such as Fantom.

Oracle Public Cloud Java Service Development Tools


Even if the Java EE 7 EG decided to postpone the PaaS features to EE 8, Oracle itself is actively working on a Java EE driven public PaaS offering. This is known since some time now and you also might have read about my first test-drives with NetBeans in the context of the Early Access program. Signs are there, that we will see the final GA version during Oracle's OpenWorld and I thought I give you some more stuff to increase your anticipation about the things to come.

Command Line Interface (CLI)
The Oracle Cloud tooling is quite impressive. You (will) have NetBeans 7.3, Eclipse OEPE and JDeveloper support and beside this you also have a couple of CLI driven tools to integrate with your build life-cycle. The base for that is the CLI interface. Two areas are supported here: First of all the remote control for your cloud service instance. So, everything you need to manage your deployment is there. You can install, update, delete, start and stop deployments. Beside that you have a hook to a couple of configuration information about your deployments, the executed jobs, your datasources and instances. The second area is the whitelist-tool. This allows you to check against the white-list before spending time on deployment circles.
Everything you need to get started with it will be in the sdk-download. At the time of writing this, it is still a 1.0.0 meant for early access. I expect that version to increase prior to GA, especially as I wasn't able to get this up and running behind a proxy. So, for now let's note that everything I show you should be doable with a proxy by additionally defining the "httpproxy" attribute with every command.

Given the following:
 java -jar javacloud.jar install -user user@domain.com -serviceinstance java -identitydomain myiddomain -path oracle-javacloud-sdk-1.0.0/samples/apps/visitors.war -application visitor 
you can install the example application located in the cloud SDK examples folder under the name visitor. If you don't specify the -password attribute you will be prompted to enter it. The white list checker should have been executed before:
java -jar whitelist.jar oracle-javacloud-sdk-1.0.0/samples/apps/visitors.war
The expected output here is:
INFO     - Whitelist validation has succeeded
If you try something caught by the white list it lists the validations accordingly:
ERROR    - There are 1 error(s) found for /SimpleSample/dist/SimpleSample.war

ERROR    - Path:/SimpleSample/dist/SimpleSample.war (1 Error)
ERROR     - Class:net.eisele.cloud.ForbiddenServlet (1 Error)
ERROR      - 1:Method exit not allowed from java.lang.System.(Line No:34 Method Name:java.lang.System->exit(int))
ERROR    - /SimpleSample/dist/SimpleSample.war Failed with 1 error(s).

ERROR    - Whitelist validation has failed with 1 error(s).

Nice so far. But what makes this very interesting is, that you can also use the same CLI to deploy to your local (on premise) instance by simply adding a little classpath magic. Most of the commands do support an optional argument 'local'. When this argument takes the value of true, the command is performed against the local Weblogic domain.
java -jar javacloud.jar install -user system -password weblogic1 -serviceinstance java -identitydomain myiddomain -local true -adminurl http://localhost:7001 -classpath oracle-javacloud-sdk-1.0.0\lib\localextension.jar:wls1035\wlserver_10.3\server\lib\weblogic.jar -path /SimpleSample/dist/SimpleSample.war -application simplesample
That was it. The output tells you what is wrong or right:
WARNING  - Application Manager is on CLI mode. No asynchronous operations will
           be available against local Weblogic Server when invoked from CLI.
<06.09.2012 18:16 Uhr MESZ> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiatin
g deploy operation for application, simplesample [archive: /temp/cloud/simplesample.war], to AdminServer .>
INFO     - The application installation operation is successfully completed.
<06.09.2012 18:16 Uhr MESZ> <Warning> <JNDI> <BEA-050001> <WLContext.close() was
 called in a different thread than the one in which it was created.>
That was easy! But the CLI isn't the only tool you have.

Maven Tooling
Based on the CLI you also have a Maven plugin which could be integrated with your build. Each command is exposed as a maven goal. The plugin jar is maven-javacloud.jar that is available in the SDK. Each goal supports all of its corresponding CLI command arguments as properties. First step is to install the plugin which is located in the lib folder of the SDK.
mvn install:install-file -Dfile=$SDK_HOME/lib/maven-javacloud.jar -DgroupId=com.oracle.cloud -DartifactId=javacloud -Dversion=1.0 -Dpackaging=jar
If this is done, you can either add it to your pom.xml or even execute it directly from the command line. To get a list of jobs from your java service all you have to do is to issue the following command:
mvn com.oracle.cloud:javacloud:listjobs -D$SDK_HOME=/oracle-javacloud-sdk-1.0.0 -Didentitydomain=myiddomain -Duser=user@domain.com -Dpassword=weblogic1 -Dserviceinstance=java
That brings up a complete list of the jobs you issued against the instance. An example could look like that:
1:Job Id                 - 27199
-----------              - -----------------------
->                       - Properties
------------             - -----------------------
Status                   - COMPLETE
Application              - MyCloud
Start Time               - Thu Aug 02 18:22:15 CEST 2012
End Time                 - Thu Aug 02 18:22:22 CEST 2012
Duration                 - 7 seconds
Last Updated Time        - Thu Aug 02 18:22:22 CEST 2012
Last Updated Description - 35 days, 22 hours, 23 minutes and 1 second ago
Operation                - Redeploy Application
Number of Logs           - 3
-------------            - -----------------------
This basically is an overview of all the status of all jobs for the given instance. You could also see the individual status for a jobid using the mvn com.oracle.cloud:javacloud:jobstatus goal. There are three logfiles available for every job: virus-scan, whitelist and the action log (deploy, redeploy). You can get any of the logfiles by using the
mvn com.oracle.cloud:javacloud:joblogfile -Djobid=27199 -Dlog=whitelist [...]
goal. But using it this way basically doesn't differ to what the CLI interface has to offer. So, let's move on to another example by integrating it into a pom.xml. There is a very good example in the SDK which contains (nearly) the complete life-cycle binding for all goals. Integrated into the <build> section it could look like this:
<build>
        <plugins>
            <plugin>
                <groupId>com.oracle.cloud</groupId>
                <artifactId>javacloud</artifactId>
                <version>1.0</version>
                <executions>
  <execution>
                        <id>install</id>
                        <phase>integration-test</phase>
                        <configuration>
                            <failonerror>true</failonerror>
                            <jobidproperty>install_job_id</jobidproperty>
                            <downloadlastlogonfailure>true</downloadlastlogonfailure>
                        </configuration>
                        <goals>
                            <goal>install</goal>
                        </goals>
                    </execution> <execution>
                        <id>installjobstatus</id>
                        <phase>integration-test</phase>
                        <configuration>
                            <jobid>${install_job_id}</jobid>
                            <waitfor>true</waitfor>
                            <failonerror>true</failonerror>
                            <downloadlastlogonfailure>true</downloadlastlogonfailure>
                        </configuration>
                        <goals>
                            <goal>jobstatus</goal>
                            <goal>listapplications</goal>
                        </goals>
                    </execution>
You see the plugin dependency followed by three goal bindings. The install goal binds to the integration-test phase and installs the app to the cloud. Remembering the jobid stuff? The <jobidproperty> tag binds the assigned jobid to the corresponding maven property and you can access it later on via  <jobid>${install_job_id}</jobid>. Nicely done! You can reinstall, start and stop your deployments and do whatever has to be done. Working with different profiles for on-premise and cloud is also possible.

ANT Tooling
Last but not least you still have the ANT version of everything I described above available. The tasks are packaged in ant-javacloud.jar that is available in the SDK. The task declaration can be found in the SDK at ant-javacloud.jar\oracle\cloud\antlib.xml and can be declared with the namespace prefix of javacloud like this:
<project name="sample-how-to-use-ant" default="all" basedir="." javacloud="antlib:oracle.javacloud.antlib">
        <!-- more of your stuff here -->
            <path id="javacloud.classpath">
                <pathelement location="${SDK_HOME}/lib/ant-javacloud.jar"/>
            </path>
            <taskdef uri="antlib:oracle.javacloud.antlib" resource="oracle/cloud/antlib.xml" classpathref="javacloud.classpath">
            <!-- required only when working against local Weblogic domain -->
            <path id="local.classpath">
                <pathelement path="${SDK_HOME}/lib/localextension.jar"/>
                <!-- optional for running whitelist validation automatically while installing -->
                <pathelement path="${SDK_HOME}/lib/whitelist.jar"/>
                <pathelement path="${WEBLOGIC.JAR}"/>
            </path>
        </project>
That is a quite complete set of tools to integrate your new Oracle Java Cloud service into your build. The Maven plugin is the one which obviously makes most sense to most of us but all the others aren't forgotten. So, be curious about when this stuff becomes publicly abailable!

As a reminder, the Oracle Public Cloud runs on Exalogic :)

Thursday, September 6, 2012

PrimeFaces Push with Atmosphere on GlassFish 3.1.2.2


PrimeFaces 3.4 came out three days ago. Beside the usual awesomeness of new and updated components it also includes the new PrimeFaces Push framework. Based on Atmosphere this is providing easy push mechanisms to your applications. Here is how to configure and run it on latest GlassFish 3.1.2.2.

Preparations
As usual you should have some Java, Maven and GlassFish installed. If you need it out of one hand give NetBeans 7.2 a try. It is the latest and greatest and comes with all the things you need for this example. Install the parts or the whole to a location of your choice and start with creating a new GlassFish domain:
asadmin create-domain pf_push
accept the default values and start your domain
asadmin start-domain pf_push
Now you have to enable Comet support for your domain. Do this either by using the http://<host>:4848/ admin ui or with the following command:
asadmin set server-config.network-config.protocols.protocol.http-1.http.comet-support-enabled="true"
That is all you have to do to configure your domain.

The Maven Project Setup
Now switch to your IDE and create a new Maven based Java EE 6 project. Add the primefaces repository to the <repositories> section and add the primefaces dependency to your project <dependencies> section or your project's pom.xml:

  <repository>
            <url>http://repository.primefaces.org/</url>
            <id>primefaces</id>
            <layout>default</layout>
            <name>Repository for library PrimeFaces 3.2</name>
        </repository>

 <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.4</version>
 </dependency>

Additionally we need the latest Atmosphere dependency (Contrats to JeanFrancois Arcand for this release)
<dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>1.0.0</version>
</dependency>
It is using Log4j and if you need to have some more output it is a good idea to also include the corresponding configuration or bridge it to JUL with slf4j. To do the later, simply include the following to your pom.xml:
 <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.6.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>1.6.6</version>
        </dependency>
There is only one thing left to do. The PrimePush component needs to have its servlet channel registered. So, open your web.xml and add the following to it:
<servlet>
        <servlet-name>Push Servlet</servlet-name>
        <servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>Push Servlet</servlet-name>
        <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
That was it! On to the code!

The Code
I'm going to use the example referred to in the PrimeFaces users guide. A very simple example which has a global counter which could be incremented.
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.push.PushContext;
import org.primefaces.push.PushContextFactory;

/**
 * Counter is a global counter where each button click increments the count
 * value and new value is pushed to all subscribers.
 *
 * @author eiselem
 */
@ManagedBean
@SessionScoped
public class GlobalCounterBean implements Serializable {

    private int count;

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public synchronized void increment() {
        count++;
        PushContext pushContext = PushContextFactory.getDefault().getPushContext(;
        pushContext.push("/counter", String.valueOf(count));
    }
}
The PushContext contains the whole magic here. It is mainly used to publish and schedule messages and manage listeners and more. It is called from your facelet. This looks simple and familiar:
<h:form id="counter">
<h:outputText id="out" value="#{globalCounterBean.count}" styleClass="display" />
<p:commandButton value="Click" actionListener="#{globalCounterBean.increment}" />
</h:form>
This basically does nothing, except incrementing the counter. So you have to add some more magic for connecting to the push channel. Add the following below the form:
<p:socket channel="/counter" >
<p:ajax event="message" update="counter:out" />
</p:socket>
<p:socket /> is the PrimeFaces component that handles the connection between the server and the browser. It does it by defining a communication channel and a callback to handle the broadcasts. The contained <p:ajax /> component listens to the message event and updates the counter field in the form. This however requires and additional server round-trip. You could also shortcut this by using a little java-script and binding the onMessage attribute to it to update the output field:

<script type="text/javascript">
function handleMessage(data) {
$('.display').html(data);
}
</script>
<p:socket onMessage="handleMessage" channel="/counter" />
That is all for now. Congratulations to your first PrimeFaces Push example. Have fun playing around with it!