Wednesday, October 29, 2008

Portal Update October 2008

This month's portal summary got a little slimmer than the others:
  • SUN: Groovy Support: WebSynergy and the associated Portal Pack 3.0 continue to add features as part of its partnership with Liferay. Besides Ruby and PHP, you can now run Groovy apps as JSR-286 portlets deployed to WebSynergy as described by Frerk Meyer.

  • Oracle (BEA): no news.

  • IBM: Finally, WebSphere Application Server 7 is out. This means that IBM has joined the Java EE 5 vendor parade. With this release, the server also supports JSR-286 portlets as described in a very detailed release post.

  • eXo: The next release of eXo Portal (v2.5) will support right-to-left (RTL) languages (see picture) like Arab or Hebrew. A wiki dedicated to this RTL framework provides more details.

  • JBoss:
    > JSR-168 Portal:
    Release of JBoss Portal 2.6.7, a maintenance release of JBoss Portal 2.6: Main improvements have been done in scalability. JBoss claims that you can tune your portal application on a 1-node environment as the new version scales linearly.

    > JSR-286 Portal: Release 2.7 is in the process to go GA.

  • Eclipse: The first milestone of Eclipse Portal Pack 2.0 has been released. The portal pack consists of three plugins: JSR-286/168 Portlet Wizard, WebSynergy Plugin and the OpenPortal Plugin.

  • NetBeans and IntelliJIDEA: no news regarding portal support.

Friday, October 24, 2008

Giving EJB 3.1 a Test Drive

Although not yet final, project GlassFish features already an alpha implementation of EJB 3.1. TheServerSide posted a nice series of articles on what you can expect to come - but honestly, wouldn't it be much more fun to actually get some hands dirty? Here's a quick description on how you can give it a spin. We will demonstrate the following new features:
  • Singleton Beans
  • Simplified EJB packaging
  • Simplified EJB without Interfaces
  • Unified JNDI naming
Start with downloading the latest release of GlassFish v3. The Windows installer guides you through the installation. Use the default settings except for the authentification - choose a username and a password (this used to default to "admin/adminadmin"). At the end you will be prompted by the Updatetool - start it and install the Add-Ons shown in the image below:

Beside the EJB Container we'll also install the new JAX-RS REST API to access the EJB. The JAX-RS JSR has just recently gone final, and is definitely also worth a look. Once the installation is done, we'll switch to the IDE to code our beans. I'm using Eclipse with the Maven 2 plugin to get started quickly.

Choose New Maven Project and select the maven-archetype-webapp archetype as shown in the screenshot below. We're naming our project "ejbtestdrive" - note the name as it will be used a couple of times in the further process. Finish the create wizard and add the src/main/java folder as a source folder in Eclipse after creating it.

To resolve our dependencies, lets first configure the Maven repositories to download the EJB 3.1 as well as the JAX-RS API. Add the following lines to your pom.xml:
<name>Glassfish Repository</name>
<name> Repository</name>

Which allows us to download following dependencies:

Almost done with the Maven setup. We'll just add the GlassFish Maven plugin to our build and set the compiler to deal with Java 6 (Java 5 should be fine too):

The referenced properties should be defined in a Maven profile, but for simplicity we'll just add them now to our POM (just replace the values with your installation location and your username/password):

You're now ready to run the WAR file on GlassFish. Just run
mvn package glassfish:deploy

to start GlassFish and get your WAR file deployed (Note: If the Maven plugin complains about asadmin not be a Win32 application, just remove the UNIX script so the .bat will be taken).

Finally, time to write some code! Go back to Eclipse and create a package. Our EJB is going to be a (surprise surprise) HelloWorld bean. Create a new class which looks like the following:
package com.ctp.ejb;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.ejb.Singleton;

* The friendly first EJB 3.1 bean.
* @author [you!]
public class HelloWorldBean {

private Set<String> names = new LinkedHashSet<String>();

public String hello(String name) {
return "Hello " + names;
In case Eclipse complains about the compiler compliance, just set the Java project facet in the project's properties to something > 1.4. You've now created one of the new Singleton EJBs. The bean is going to remember everybody who said "hello" and give back a friendly greeting. Note that there is no local or remote interface at all! Also using a global state in a bean is something nasty to achieve before EJB 3.1. Run
mvn package glassfish:redeploy

to deploy your bean - noteably in just a simple WAR file! Did you notice how fast this deploys?

Now it's time to access our bean over JAX-RS. Create another class which looks like this:
package com.ctp.ejb;

import javax.naming.InitialContext;

* A RESTful bean being hopefully quite busy!
* @author [you!]
public class HelloWorld {

public String hello(@PathParam("username") String name) throws Exception {
HelloWorldBean hello = (HelloWorldBean)
new InitialContext().lookup("java:global/ejbtestdrive/HelloWorldBean");
return hello.hello(name);

Simple enough, right? This is taking requests under /hello/... with a username, looking up the bean in JNDI and call it's hello method. Did you notice the format of the JNDI lookup? Yes, this is finally standardized, making your applications much more portable! In case you named your application differently, make sure the names match between global/ and /HelloWorldBean.
Further details on the JAX-RS functionalities can be found here.

As a last step, we need to add the Jersey servlet to our web.xml. Modify it to match this snippet:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
<servlet-name>Jersey Web Application</servlet-name>
<servlet-name>Jersey Web Application</servlet-name>

Check that your package name matches in the Servlets init param. Now package and redeploy - and we're ready to go! Just go to http://localhost:8080/ejbtestdrive/hello/[your name] to see you greeted by your new EJB! Experiment with different names and browser sessions and see the global state preserved.

Hope you enjoyed this little test drive. Let us know on how you're using EJB 3.1 and what your experience is with it!

Sunday, October 19, 2008

Java People Spotlight: Piyush Shah

"People Spotlight" is going to bring some light into the undercover hacker rooms at CTP where Piyush is getting his hands dirty on new frameworks and technologies. The picture tells both: his strong developer skills as well as his social engagements at CTP being official "CTP Staff" of the Social Committee...Enjoy!

Java Community Role:
Developer [aka 0800-DEBUG: "Who you gonna call?" - "Bug-Shah Buster!!!!"]
My Master Kung-Fu Skills
Apache Tomcat 6, WebLogic 10, Javascript
I'd be excited to get my hands dirty on:
Spring and JBoss Seam


Q: Hi Piyush, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: Trying to break and rebuild Interwoven Teamsite to incorporate Xopus.

What was the greates piece of code you have ever written so far?
A: request.getRequestDispatcher(URL).forward(request, response);

Q: What is the best quote you have ever heard from one of your peers?
A: "Developing an application is like making a movie"

Q: What is the best quote you have heard from our managers?
A: "XYZ technology, you can do it. It’s a piece of cake."

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: Porting my custom code using SSH client on Solaris server and making sure it is Java1.4 compatible.

Q: What is your favorite podcast?
A: TSS (

Q: Which Java book can you recommend?
A: SCJP6 - by Katherine Sierra

Tuesday, October 7, 2008

Java People Spotlight: Douglas Rodrigues

Our "People Spotlight" series continues with an official JUG Brazil member... "Braziiiiiiiiiiiiiiiiiiiiiiiil !!! ;-) ". Besides contributing his excellence to CTP's Java Community, Douglas makes sure that Brazil stays the number 2 in the list of the countries with most hits to this blog! ;-) ... and here are Douglas answers:

Java Community Role:
Developer [aka Java Code Spitter]
My Master Kung-Fu Skills
Write code that (almost) anyone can read and understand in the future.
I'd be excited to get my hands dirty on:
JBoss DNA and IntelliJ IDEA 8.


Q: Hi Douglas, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: while (!weekend) {; while (!night) {; doCode(); iTunes.pause(); getCoffee(); } iTunes = null; } // One-liners rocks! \o/
Q': and where is the exception handling??!!! ;-)

Q: What was the greates piece of code you have ever written so far?
A: An image to HTML converter. It takes a 30kB image and produces a 5MB HTML file.

Q: What is the best quote you have ever heard about programming?
A: "The nice thing about standards is that there are so many of them to choose from", by Andrew S. Tanenbaum.

Q: What is the best quote you have heard from our managers?
A: Well, I hear "we're all in sales" at least once every month.

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: Java Content Repository API (JCR).

Q: What is your favorite podcast?
A: I'm not a big fan of technology related podcasts, but I tried Java Posse and it's kinda funny.

Q: Which Java book can you recommend and for what reason?
A: Head First Design Patterns