Skip navigation

So I was invite by Miracle to give a talk about OpenShift at MOW2012.

IMG_20120419_170453.jpg

Few words about Miracle Open World, it used to be an Oracle Database conference but starting last year they opened the tracks and had "company tracks" such as Oracle Track and Microsoft Track. This year there were various tracks such as Programming Language, Cloud and Virtualization, Middleware, Databases, Performance, Mobile which was much more appealing IMO.

 

The Miracle company remimded me of the old JBoss Days, a family around a charismatic CEO named Mogens Norgaard, he introduced a funny serie of Oracle DB installations after hearing that IBM was charging 50 hours for it. For instance they made a movie showing how to install it in two hours with the only help of a nose.

 

Anyway, turning in Database conference into a broader conference is a challenge and unfortunately it seems like they weren't heard. The audience was missing as well as money to sponsor their famous beach party which was replaced this year (with a lot of humour) by a large pool in a kit... (Freezing at this time of the year)

 

I attended one of the most successful session there around C#/.Net to write mobile applications for Windows mobile, Android and iOS http://mow2012.dk/program/cross-platform-mobile-applications-with-c-and-net.aspx. The promise to build once for multiple devices surely attracted most of the audience, ultimately the presentation remains to the level that you could build .Net libraries that could be reused in multiple environments.

 

In any case, I got to learn more in areas where I don't usually go and on top of that I got to learn how to open a beer with another beer thanks to Max Rydahl Andersen and all the other Danish guys there for whom it seemed very natural... (In France and Switzerland we use what we call a "bottle opener" it's also a good marketing goodie. Note to marketing people, this kind of goodie is useless in Denmark).

 

I also got a chance to meet for the first time other Red Hat colleagues which is always good !

 

Oh and last, I got to quickly visit LegoLand as the conference was in the LegoLand hotel.IMG_20120420_101158.jpg

In a previous blog post, I showed how to run a Play application into JBoss AS 7. This time since JBoss AS7 is now available on OpenShift Express we are going to deploy that exact same application on this free offering.

 

Environment

For this blog and related video, I'm using Linux (Fedora 15) and Play 1.2.2. The tools are also available for Mac and Windows.

Installation

We'll assume that you already have Play configured as in the previous post.

You will need an OpenShift Express account if you do not have one already, you can subscribe here. During the sign up process you will be led to a page explaining how to install the Red Hat Cloud tools.

 

You can also find a video about installing the tools on an RPM-based Linux distribution here.

 

If your environment is correctly setup you should:

  • be able to run the play command (watch out the 'play' music player on Linux...)
  • be able to run the rhc commands such as rhc-user-info
  • be able to login on https://openshift.redhat.com/app/login with the username and password you chose during registration

The video at the bottom of this page will assume that the environment is already setup.

Create an OpenShift Express domain and application

The first thing to do with a new account is to create a domain. A domain can contain multiple apps.

The domain name will appear in the URL of your application according to the following scheme:

http://<application name>-<domain-name>.rhcloud.com

So pick a domain name that you can be proud of

To create a domain named play for the username theute@redhat.com (but that one is now used for this demo so you will need to create a new name):

rhc-create-domain -n play -l theute@redhat.com

And you should be prompted for your password:

Password: 
Generating OpenShift Express ssh key to /home/theute/.ssh/libra_id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/theute/.ssh/libra_id_rsa.
Your public key has been saved in /home/theute/.ssh/libra_id_rsa.pub.
The key fingerprint is:
cb:50:b0:08:4f:52:5b:af:6d:a7:1a:e3:96:af:47:89 theute@desktop.heute
The key's randomart image is:
+--[ RSA 2048]----+
|  o.o o          |
|   = + +         |
|    + . o        |
|       +         |
|      o.S..      |
|      E+o+       |
|      oo+        |
|     .o+.        |
|     .++.        |
+-----------------+

Contacting https://openshift.redhat.com
Creation successful


You may now create an application.  Please make note of your local config file
in /home/theute/.openshift/express.conf which has been created and populated for you.

 

The domain has been successfully created !

Note: From now on, the default user will be theute@redhat.com and I won't need to specify it in the subsequent commands.

 

Now that the domain exist, we will want to create a new application, taking the JBoss AS 7 cartridge. To do so we will need to give it a name and specify the type of cartridge.

rhc-create-app -a booking -t jbossas-7.0

And you will be asked for the password again:

Password: 


Found a bug? Post to the forum and we'll get right on it.
    IRC: #openshift on freenode
    Forums: https://www.redhat.com/openshift/forums


Attempting to create remote application space: booking
Contacting https://openshift.redhat.com


RESULT:
Successfully created application: booking


Checking ~/.ssh/config
Contacting https://openshift.redhat.com
    Adding rhcloud.com to ~/.ssh/config
Now your new domain name is being populated worldwide (this might take a minute)...
Pulling new repo down
Warning: Permanently added 'booking-play.rhcloud.com,67.202.44.44' (RSA) to the list of known hosts.
Confirming application booking is available
  Attempt # 1


Success!  Your application is now published here:


      http://booking-play.rhcloud.com/


The remote repository is located here:


    ssh://21080154349345648355846370ea5738@booking-play.rhcloud.com/~/git/booking.git/


To make changes to your application, commit to booking/.
Then run 'git push' to update your OpenShift Express space

To measure your progress you can go to the URL mentionned (http://booking-play.rhcloud.com/ in my case) to see your first AS7 application running on OpenShift in action.

as7cartridge.pngNow that we have this application up and running, we can now deploy our Play application (the booking demo).

All the deployment is done using GIT. You will need to know a little bit about git, but the main commands will be used here (how to commit and push the changes).

Deploying the Play application

During the application creation, the command also clone the GIT repository locally in a folder named as your application (booking in our example).

It will look like this:

.
|-- deployments
|-- .openshift
|   |-- action_hooks
|   |   `-- build
|   |-- config
|   |   `-- standalone.xml
|   `-- markers
|       `-- README
|-- pom.xml
|-- README
`-- src
    `-- main
        |-- java
        |-- resources
        `-- webapp
            |-- health.jsp
            |-- images
            |   `-- jbosscorp_logo.png
            |-- index.html
            |-- samples
            |   |-- weld-login.war
            |   |-- weld-numberguess.war
            |   `-- weld-translator.ear
            |-- snoop.jsp
            `-- WEB-INF
                `-- web.xml

The pom.xml file and src directory is a Maven project, it's actually the webapplication that is shown on the screenshot above.

There are mainly two ways to deploy an application for JBoss AS 7 on OpenShift, either:

  • You edit the files in src and on each git push the project will be compiled and deployed for you (pushing sources)
  • You push a ready-to-go war file (pushing binaries)

Since our booking project isn't a Maven project, we will push a web archive directly and we will not need the pom.xml and src directory.

To remove those files, go to the GIT clone of your application and type:

git rm -rf pom.xml src

We can already commit that change:

git commit -m "Removing useless application"

Now similarly to what we've done in the previous blog entry, we will want to create a war from the booking play application.

Go to $PLAY_HOME/samples-and-tests then execute (after replacing /home/theute/booking, by the actual location of your GIT clone):

 

play war booking -o /home/theute/booking/deployments/booking.war

 

And you should get something like:

~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.2, http://www.playframework.org
~
Listening for transport dt_socket at address: 8000
14:14:43,652 INFO  ~ Starting /home/theute/Projects/Play/play-1.2.2/samples-and-tests/booking
14:14:44,425 INFO  ~ Precompiling ...
14:14:49,560 INFO  ~ Done.


~ Packaging current version of the framework and the application to /home/theute/booking/deployments/booking.war ...
~ Done !
~
~ You can now load  as a standard WAR into your servlet container
~ You can't use play standard commands to run/stop/debug the WAR application...
~ ... just use your servlet container commands instead
~
~ Have fun!
~

Now the last thing we need to do for JBoss AS 7 and since it is an exploded archive is to create a file named after our WAR name and siffixed by .dodeploy, this file needs to sit next to the booking.war folder:

 

touch /home/theute/booking/deployments/booking.war.dodeploy

 

At this point our GIT clone looks like:

.
|-- deployments
|   |-- booking.war.dodeploy

|   `-- booking.war
|       `-- WEB-INF
|           |-- application
|           |   |-- **
|           |-- classes
|           |   |-- application.conf
|           |   |-- data.yml
|           |   |-- messages
|           |   `-- routes
|           |-- framework
|           |   `-- **
|           |-- lib
|           |   |-- **
|           |-- resources
|           |   `-- messages
|           `-- web.xml
|-- .openshift
|   |-- action_hooks
|   |   `-- build
|   |-- config
|   |   `-- standalone.xml
|   `-- markers
|       `-- README
`-- README

 

We simply need to push our changes:

git add deployments/booking.war*
git commit -m "Adding Play Application"
git push

The last command will take some time the first time as the play application embeds a lot of (unused) libraries (25MB of files in total to upload). Next push would be much faster.

You should see the following:

Counting objects: 215, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (199/199), done.
Writing objects: 100% (213/213), 25.62 MiB | 51 KiB/s, done.
Total 213 (delta 26), reused 0 (delta 0)
remote: Stopping application...
remote: done
remote: Found .openshift/config/standalone.xml... copying to /var/lib/libra/21080154349345648355846370ea5738/booking/jbossas-7.0/standalone/configuration/
remote: running .openshift/action_hooks/build
remote: Starting application...done
To ssh://21080154349345648355846370ea5738@booking-play.rhcloud.com/~/git/booking.git/
   ab9b0c1..51b68b3  master -> master

Now go to your address similar to http://booking-play.rhcloud.com/booking/ (this one should actually be running too) and you should see and be able to start using the application:

booking.png

Next in the serie will be how to use MySQL as storage instead of H2 in memory (as currently setup).

 

I hope you enjoyed this little explanation, now you can see the same steps in action on this video:

 

Now that JBoss 7 CR1 is out, let's play with it.

Because of standards, it should be straightforward to run a Play application packaged as a war in JBoss AS7.

 

Step 1: Download and Install Play

Grab Play framework here and unzip it in the location of you choice, we'll call that location $PLAY_HOME and make sure $PLAY_HOME is in your path.

 

Step 2: Verify installation

Type:

play

and you should see:

~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.1, http://www.playframework.org
~
~ Usage: play cmd [app_path] [--options]
~ 
~ with,  new      Create a new application
~        run      Run the application in the current shell
~        help     Show play help
~


Step 3: Download and install JBoss AS 7

Get a copy of JBoss AS 7 here. Unzip it and we'll name the home directory of AS7 $JBOSS_HOME.

To verify that the installation went well, go to $JBOSS_HOME/bin and type:

standalone.sh

or

standalone.bat

You will see something like:

=========================================================================


  JBoss Bootstrap Environment


  JBOSS_HOME: /tmp/jboss-7.0.0.CR1


  JAVA: java


  JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman


=========================================================================


11:23:59,956 INFO  [org.jboss.modules] JBoss Modules version 1.0.0.CR4
11:24:00,262 INFO  [org.jboss.msc] JBoss MSC version 1.0.0.CR2
11:24:00,321 INFO  [org.jboss.as] JBoss AS 7.0.0.CR1 "White Rabbit" starting
11:24:01,326 INFO  [org.jboss.as] creating http management service using network interface (management) port (9990) securePort (-1)
11:24:01,336 INFO  [org.jboss.as.logging] Removing bootstrap log handlers
11:24:01,351 INFO  [org.jboss.as.connector.subsystems.datasources] (Controller Boot Thread) Deploying JDBC-compliant driver class org.h2.Driver (version 1.2)
11:24:01,543 INFO  [org.jboss.as.naming] (Controller Boot Thread) Activating Naming Subsystem
11:24:01,562 INFO  [org.jboss.as.naming] (MSC service thread 1-4) Starting Naming Service 
11:24:01,576 INFO  [org.jboss.as.osgi] (Controller Boot Thread) Activating OSGi Subsystem
11:24:01,598 INFO  [org.jboss.as.security] (Controller Boot Thread) Activating Security Subsystem
11:24:01,606 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 3.2.0.Beta2
11:24:01,631 INFO  [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.0.Beta3
11:24:01,665 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.0.Beta3
11:24:01,862 INFO  [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-1) The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
11:24:01,908 INFO  [org.jboss.as.ee] (Controller Boot Thread) Activating EE subsystem
11:24:01,937 INFO  [org.jboss.as.jmx.JMXConnectorService] (MSC service thread 1-3) Starting remote JMX connector
11:24:01,959 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) Listening on /127.0.0.1:9999
11:24:01,990 WARN  [org.jboss.osgi.framework.internal.URLHandlerPlugin] (MSC service thread 1-2) Unable to set the URLStreamHandlerFactory
11:24:02,012 WARN  [org.jboss.osgi.framework.internal.URLHandlerPlugin] (MSC service thread 1-2) Unable to set the ContentHandlerFactory
11:24:02,383 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
11:24:02,603 INFO  [org.jboss.as.connector] (MSC service thread 1-2) Starting JCA Subsystem (JBoss IronJacamar 1.0.0.CR2)
11:24:02,750 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) Bound data source [java:jboss/datasources/ExampleDS]
11:24:03,318 INFO  [org.jboss.as.deployment] (MSC service thread 1-1) Started FileSystemDeploymentService for directory /tmp/jboss-7.0.0.CR1/standalone/deployments
11:24:03,345 INFO  [org.jboss.as] (Controller Boot Thread) JBoss AS 7.0.0.CR1 "White Rabbit" started in 3742ms - Started 91 of 146 services (55 services are passive or on-demand)

Now point your web browser to localhost:8080 and you should see:

as7.png

Step 4: Package a Play application as a Web Archive (WAR)

We will take the "booking" application that comes with play and is a replicate of the famous booking sample application for Seam.

Warning: For 'some' reason, the #{welcome /} inclusion of Play doesn't work in the servlet environment, so if you try to create a new application from scratch, don't be surpised to not see all the content.

 

In $PLAY_HOME/samples-and-tests/ type:

play war booking -o /tmp/jboss-7.0.0.CR1/standalone/deployments/booking.war

You should see in JBoss AS log (if  you still have it running):

11:30:04,645 INFO  [org.jboss.as.deployment] (DeploymentScanner-threads - 1) Found booking.war in deployment directory. To trigger deployment create a file called booking.war.dodeploy

We'll just do what it says and create an empty file next to booking.war called booking.war.dodeploy. This file is just a marker to tell the application server that all files have been copied and it's ready to be deployed since we haven't zipped the war.

So create that empty file (with a text editor or simply using touch if you are on a linux/Mac machine)

touch $JBOSS_HOME/standalone/deployments/booking.war.dodeploy

And you should see in JBoss AS log:

12:03:18,020 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "booking.war"
12:03:19,976 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
12:03:19,985 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
12:03:19,985 WARN  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) Unable to instantiate driver class "com.mysql.jdbc.Driver": org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.booking_war is already registered
12:03:20,149 INFO  [stdout] (MSC service thread 1-2) 12:03:20,148 INFO  ~ Starting /tmp/jboss-7.0.0.CR1/standalone/deployments/booking.war/WEB-INF/application
12:03:20,217 INFO  [stdout] (MSC service thread 1-2) 12:03:20,217 INFO  ~ Application is precompiled
12:03:20,889 INFO  [stdout] (MSC service thread 1-2) 12:03:20,889 INFO  ~ Connected to jdbc:h2:mem:play;MODE=MYSQL
12:03:21,328 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-2) Hibernate Validator 4.1.0.Final
12:03:21,335 INFO  [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-2) Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
12:03:21,427 INFO  [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-2) Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
12:03:21,436 INFO  [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-2) Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
12:03:21,722 INFO  [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-2) Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
12:03:22,205 INFO  [stdout] (MSC service thread 1-2) 12:03:22,205 INFO  ~ Application 'Hotel Booking' is now started !
12:03:22,963 INFO  [stdout] (MSC service thread 1-2) 12:03:22,963 WARN  ~ Precompiled template /conf/data.yml not found, trying to load it dynamically...
12:03:23,750 INFO  [stdout] (MSC service thread 1-2) 12:03:23,750 INFO  ~ Forcing PROD mode because deploying as a war file.
12:03:23,760 INFO  [org.jboss.web] (MSC service thread 1-2) registering web context: /booking
12:03:23,767 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "booking.war"

Now point your browser to http://localhost:8080/booking and you will see:

booking.png

And that's it, the application is now running in the best application server in the world , you can go ahead and use the services provided by a Java EE container, including application management.

 

This was my first experience with Play Framework on AS7 a better experience would be to remove the Servlet layer and hit JBoss Netty directly to get the best of both worlds. Any volunteer to work on that ?

 

See this in action on this video (Bare with me, first video and upload issues with the processed version on Vimeo, so it is very rough)

 

Enjoy !

 

You can't have missed the release of JBoss Seam 1.0.1, Gavin blogged about the release of the GA version as well as the 1.0.1 fixing some bugs. But just in case that you were out of Earth for the past two weeks, here are some links:

 

The press also picked up on that news, sometime presenting Seam as an Ajax framework (it is not, even though we provide a very convenient way to call Seam components remotely through 'Ajax') sometime presenting it right like here:

Success stories

 

But this is not the main reason for this blog entry. I am very thankful to the people who dared to designing their applications on JBoss Seam before the final release and had to go through the pain of internal changes, this is also the time to share with you two success stories that i hear of and can publicly talk about.

 

With no order of preference, i will start with Lexicon Genetics who won the JBoss World Innovation Award in the category "New Generation Technology", the application's goal was to manage hundred of thousands of mice and their semen. It was interesting to hear from Buckley Kohlhauff and Mark Ma how managing all those mice was a mission critical task and how automatic-replication of those animals can be a problem. I am also very glad to hear that to some extend our technology is being used by people who are looking for treatments for human disease.

 

 

 

The second story that i can publicly talk about is from the senior consultant Sebastien Guimont and the team he's in from Covansys, their application is about managing contracts to buy bulls and sell their semen ! Yes again, animal semen... Don't ask me why :) They mainly used the workspace management, jBPM workflow, remoting and localization components of Seam.

 

That said, i would enjoy hearing more stories about how you use Seam in your projects related to semen or not. Please email me at thomas.heute@jboss.com or use the forum.

Seam talks and reviewing



If you want a Seam presentation at a JBoss User Group or Java user Group let us know ! We can come if this is for a large audience or we can help you to do the presentation yourself. In the same direction, if you need reviews for articles or chapters of books concerning Seam e email me at let me know, we will be happy to make sure that no mistake is being printed out.

For francophones in Paris

 

To finish with, i will be presenting JBoss Seam (in French) at the Paris JBoss User Group next Wednesday (June 28th), i will be glad to meet you if you are around. I will share my time with Jean-Marie Lapeyre who will talk about the French online tax declaration system running on JBoss AS that just passed its highest load for this year.

 

Thomas Heute - JBoss Seam project leader

Thomas Heute

Seam's update

Posted by Thomas Heute Apr 12, 2006
In case you were not around the forums or starring at the CVS commits for the last month you may have missed some of the new features implemented since the Beta 2 version. Let me summarize here the progress that has been made and that is available in the CVS.
  • The internationalization has been dramatically improved. It is now very easy to switch from one language to the other, the internaltionalization support is shown in the "issues" example.
  • Ajax support, you can now directly call your business methods of your Seam components directly from your Javascript code. See how it works in the "remoting/helloworld" example.
  • It is quite common when you navigate on a website to wait for an action to perform, without really knowing if things are working. As users we accept it, and little attention is made to accomodate us because of the troubles to display a progress status to the end user. Well, that should be past. Thanks to the AJAX progress bar in Seam, there is no reason to hide the progress of an action to the end user anymore. Oh and again, there is an example in "remoting/progressbar".
  • Since asynchronous messaging and AJAX fit well together, you can also effectively use JMS within your Seam applications. The "remoting/chatroom" example, is showing you how you can use Ajax+JMS to publish a message to all subscribers without having to refresh a page.
  • Gavin also implemented a simple blog example he explains why and how in his blog entry: Comparing web frameworks: Seam
  • Back button support is now also working for pageflows (stateful navigation)
That said, i want to publicly thanks Shane Bryzak who really worked hard on the Ajax support and JMS support, not only he implemented the support itself but he also produced documentation and examples ! Thank you Shane. That said, we are always pleased to hear your feedback in the dedicated forum.
Seamlessly yours, ThomasH

 

I am just back from Javapolis, it was such a nice experience. I was there to do a talk about our so loved project JBoss Seam. It was amazing to see the 750 seats movie theater room full of people even more when we know that the talk was "competing" with Julien Viet's presentation about JBoss Portal. Anyway i am very thankful to the people who gave me 1 hour to explain them the main concepts of Seam.

 

Once the presentation was over, at the JBoss cocktail party i was also surprised how well the public was educated on Seam, it is probably due to the JavaNews magazine publishing my article.

 

The speaker dinner was quite interesting too, we just sat wherever we could and just by chance i was at the table with the Wicket, Webwork and RIFE guys, it was definitely the web framework table ! It is good to see that nobody felt like we were competitors, i really enjoyed their company.

 

The big news for me, was that Oracle decided to give away their ADF components to MyFaces. That is a great thing for MyFaces and us, now we are all waiting for a JSF 1.2 implementation ;)

 

I did not spend enough time to check around on other presentations but meeting people there was just great, Stephan Janssen the organizer of the event is really a nice guy and makes everything smooth for everybody. Well done the Javapolis team !

 

JBoss Seam is using lot of annotations and very few XML for reasons that i will explain here.

 

First i thought of calling this blog entry "annotations vs XML" but it isn't fair. It's not about who is the winner but when it is more appropriate plus it is often an endless question like "Linux vs Windows" or "XBox 360 vs PS3" (it is good to have both).

I love XML

 

Back in 2001 my first real job at NIST was helping with defining, then implementing a RI and finally start building a test framework for the registry and repository part of ebXML. ebXML is supposed to be adapted to work for any kind of business and we worked on two different demonstrations one for motherboard manufacturers repositories and one for e-Learning courses repositories. It made lot of sense to use XML as metadata for those things, XML is really cool, i can read and write it with any editor, i can parse it really easily with those libraries available out there. Most important i can add metadata about images and other binary documents since i am using an external file just referencing the embedded binary or filename.

 

For all those reasons XML was totally appropriate

 

Now i want to add metadata on a java source file.

Back to the old <not so> good time

 

Back in the old not so simple EJB*2* time, i had to write my java file, then go tweak a file which i never remembered the name and the syntax, even worse i had to switch file everytime i was writing a method and in Eclipse it's not as simple to switch file as in emacs ! I often messed up with method names, typos became nightmares, but here came XDoclet ! I don't have to write my classname and method names twice, i don't have to learn the XML syntax, i just have to go on the XDoclet website and look through the cheatsheets, thank you God Xdoclet, i don't have to maintain parallel files anymore and i save *a lot of time* thanks to you.

 

The drawback is that i had to learn that again to explain to JBoss students how to do the traditional way, when i explained XDoclet method afterward, i was about to get killed for not explaining that at first.

 

Now that Java imported the Xdoclet basic idea right into JSE 5 by using annotations (aka JSR 175) it is even easier.

 

There are now lot of things that i want to declare on my POJOs, not only what kind of beans they are but also their Seam name, i probably want to use Hibernate annotations to specify some validation and so on. I will loose time if i have to switch to an XML file specify the classname, the method name and the validation furthermore i will probably do typos and realize it on deployment time and finally if i change my method name, my IDE refactoring super-feature will or will not change it in the XML file.

 

It makes lot of sense to have an email validator on my email field, why would i declare this outside of my POJO. There is just no reason for that.

 

The only good point i see in this case for outside metadata is when you want to keep the same POJO for different clients and they have different requirements (and i know they all have) in terms of password and username length for example.

Conclusion, I love annotations even more

 

XML forces people to be aware of the connection between a class file and it's file descriptor and to keep them synchronized, while it looks like a little work it appears to be a big time consumer for most of us. In my opinion in a 1-1 relationship between a java class element and it's metadata, annotation is a much nicer way to achieve the goal of marking a method or a field.

Thomas Heute - JBoss Seam project leader

 

It is with lot of excitement and happiness that we released today the very first version of JBoss Seam. Seam is an application framework for Java EE 5. It unifies the component models of JSF and EJB 3.0, providing a streamlined programming model for web-based enterprise applications.

 

Seam also helps you integrate jBPM process definitions right into your application.

 

I have a lot of pointers for you since we worked hard on having documentation and examples ready at release date.

 

In the package, on top of the hotel booking example, we offer a simpler version representing the registration part of many web application, the hotel booking example using Hibernate instead of EJB and finally an example integrating a jBPM process definition.

 

Now if you want to discover Seam from us, Gavin King and I will present Seam at the JBoss World Barcelona event on October 10-12th

 

Many thanks to Jacob Hookom, project leader of Facelets and member of the JSF expert group for being the first contributor of Seam :)

 

Thomas Heute - JBoss Seam project leader