Michael Yuan

“Science is a wonderful thing if one does not have to earn one’s living at it” — Albert Einstein

October 24th, 2007

New England Foliage

I love to visit New England in the fall. At the first whim of winter, the entire forest explodes into bright red / yellow / orange. Last glory from the fleeting summer before the first snow turns them all white! The scenery is breath-taking no matter whether you are viewing from the air, along the highway, on a back road, or even just in front of a single tree. Well, I got to experience all these view points during my trip to Boston last week.

Despite the bad weather and horrendous flight delays, the magnificent view made the trip all the worthwhile. Click on the follow pictures to enter the photo album.

DSC_7289.jpg

DSC_7420.jpg

October 24th, 2007

Slides for Seam talk at the New England JUG

I gave a 2-hour talk on JBoss Seam in the New England Java User’s Group last Thursday. Although the talk was at the same night as a crucial game for Red Sox, it still managed to attract 250+ people — making it one of largest JUG meetings I have ever attended! I had a great time there, and learned first hand about how Java developers in the Boston area are using JBoss Seam to solve real world problems. For those who are interested, the presentation itself can be found here:

Slides for the JBoss Seam presentation in NEJUG, Oct 18th 2007

I enjoyed a “re-union” with my Red Hat colleagues in the Boston area: Shelly McGowan, Chantal Yang, Bill Burke, Kurt Stam, and Rajesh Rajasekaran. Thank you guys for making the meeting a success! In addition, I’d also like to thank Mark Johnson (the president of the NEJUG), Heather Fox (publicist at Prentice Hall), and Shaun Connolly (my sponsor at Red Hat) for organizing everything!

Finally, a couple of references to things I mentioned in the meeting:

October 23rd, 2007

Nominate your products / projects for the 18th Jolts Award

Dr Dobb’s Journal’s Jolt award is one of the longest running and most prestigious awards in the software industry. The 18th Jolt Award is now open for nominations:

http://www.joltnominations.com/Jolt/

Hint: If you develop tools for mobile applications, Jolt does have a category for mobile tools. I will participate in this category heavily this year.

To be qualified for Jolts, you have to submit your own product — there is a small submission fee ($50 for open source projects) to cover admin costs. As a Jolt judge for the past several years, I can tell you that none of the judges is paid. We are all volunteers contributing our time for free to go through the complicated software evaluation process. What do we get out of it? Well, we get exposure to the latest happenings in the industry and get to put “Jolts Judge” on our name cards. ;)

What do you get out of it? Well, if your product wins Jolts, that gives you some major bragging right! Even if your product does not win, by participating in the process, you get Jolt judges (most of them are consultants influencing purchasing decisions) to look carefully at your product. If some of the judges like your product, they might blog about it or recommend it in their consulting work.

In the past several years, we got an overwhelming number of submissions every year. It is nearly impossible to evaluate each of them in detail, if the judges are not already using the product in his/her daily work. So, it will be enormously helpful if you can prepare a flash or live demo of your product to illustrate the key features that differentiates your product from the rest.

October 9th, 2007

JBoss Seam project setup with Maven — Part 2: EAR deployment

In a previous post, I discussed how to setup a Maven project for your Seam WAR application. However, most Seam developers are probably working on applications with EJB3 components to fully take advantage of the service infrastructure of the JBoss AS container. So, to complete this series, I setup a maven project for Seam EAR deployment. The project structure is as follows. The ejb module builds the JAR for EJB3 components; the war project build the web application; and the ear module builds the EAR application with necessary library JARs.

CODE:
  1. .
  2.  |-- pom.xml
  3.  |
  4.  |-- ear
  5.  |   `-- pom.xml
  6.  |
  7.  |-- ejb
  8.  |   |-- pom.xml
  9.  |   |-- src
  10.  |       `-- main
  11.  |           |-- java
  12.  |           |    `-- com
  13.  |           |         `-- example
  14.  |           |               `-- ejb
  15.  |           |                    |-- MyEnterpriseBeanImpl.java
  16.  |           |                    `-- MyEnterpriseBean.java
  17.  |            `-- resources
  18.  |                |-- seam.properties
  19.  |                 `--  ejb-jar.xml
  20.  |
  21.  |-- war
  22.       |-- pom.xml
  23.        `-- src
  24.             `-- main
  25.                  |-- java
  26.                  |   `-- com
  27.                  |       `-- example
  28.                  |             `-- SampleAction.java (and other Java source files)
  29.                  |-- resources
  30.                  |   |-- META-INF
  31.                  |   |   `-- persistence.xml
  32.                  |   |-- messages.properties
  33.                  |   `-- seam.properties
  34.                  `-- webapp
  35.                      |-- WEB-INF
  36.                      |    | -- components.xml
  37.                      |    | -- pages.xml
  38.                      |    | -- face-config.xml
  39.                      |     `-- web.xml
  40.                      `-- hello.xhtml (and other web content, CSS, templates, and images)

The main pom.xml file defines the shared libraries required by all modules. It optionally uses the Seam parent POM to set the version numbers for the dependency JARs. Here is how it might look like:

XML:
  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  2.  
  3.   <repositories>
  4.     <repository>
  5.       <id>jboss-snapshot</id>
  6.       <name>The JBoss maven repo</name>
  7.       <url>http://snapshots.jboss.org/maven2</url>
  8.     </repository>
  9.   </repositories>
  10.   <parent>
  11.     <groupId>org.jboss.seam</groupId>
  12.     <artifactId>root</artifactId>
  13.     <version>2.0.0-SNAPSHOT</version>
  14.   </parent>
  15.  
  16.   <modelVersion>4.0.0</modelVersion>
  17.   <groupId>mystuff</groupId>
  18.   <artifactId>mystuff</artifactId>
  19.   <packaging>pom</packaging>
  20.   <version>1.0</version>
  21.   <name>mystuff</name>
  22.   <url>http://maven.apache.org</url>
  23.  
  24.   <dependencies>
  25.  
  26.     <dependency>
  27.       <groupId>log4j</groupId>
  28.       <artifactId>log4j</artifactId>
  29.       <scope>provided</scope>
  30.     </dependency>
  31.  
  32.     <dependency>
  33.       <groupId>junit</groupId>
  34.       <artifactId>junit</artifactId>
  35.       <scope>test</scope>
  36.     </dependency>
  37.  
  38.   </dependencies>
  39.  
  40.   <modules>
  41.     <module>ejb</module>
  42.     <module>war</module>
  43.     <module>ear</module>
  44.   </modules>
  45.  
  46.   <build>
  47.     <plugins>
  48.       <plugin>
  49.         <groupId>org.apache.maven.plugins</groupId>
  50.         <artifactId>maven-compiler-plugin</artifactId>
  51.         <configuration>
  52.           <source>1.5</source>
  53.           <target>1.5</target>
  54.         </configuration>
  55.       </plugin>
  56.     </plugins>
  57.   </build>
  58. </project>

The ejb/pom.xml file defines the dependencies for the EJB3 module. Everything here is in the provided scope -- unless testing-specific libraries, which are in the test scope.

XML:
  1. <project>
  2.  
  3.   <parent>
  4.     <artifactId>mystuff</artifactId>
  5.     <groupId>mystuff</groupId>
  6.     <version>1.0</version>
  7.   </parent>
  8.  
  9.   <modelVersion>4.0.0</modelVersion>
  10.   <groupId>mystuff</groupId>
  11.   <artifactId>ejb</artifactId>
  12.   <name>mystuff - ejb</name>
  13.   <version>1.0</version>
  14.   <url>http://maven.apache.org</url>
  15.  
  16.   <build>
  17.     <finalName>ejb</finalName>
  18.   </build>
  19.  
  20.   <dependencies>
  21.  
  22.     <dependency>
  23.       <groupId>org.hibernate</groupId>
  24.       <artifactId>hibernate</artifactId>
  25.       <scope>provided</scope>
  26.     </dependency>   
  27.  
  28.     <dependency>
  29.       <groupId>org.hibernate</groupId>
  30.       <artifactId>hibernate-entitymanager</artifactId>
  31.       <scope>provided</scope>
  32.     </dependency>
  33.  
  34.     <dependency>
  35.       <groupId>org.hibernate</groupId>
  36.       <artifactId>hibernate-annotations</artifactId>
  37.       <scope>provided</scope>
  38.     </dependency>
  39.  
  40.     <dependency>
  41.       <groupId>org.hibernate</groupId>
  42.       <artifactId>hibernate-validator</artifactId>
  43.       <scope>provided</scope>
  44.     </dependency>
  45.  
  46.     <dependency>
  47.       <groupId>org.jboss.seam</groupId>
  48.       <artifactId>jboss-seam</artifactId>
  49.       <scope>provided</scope>
  50.     </dependency>
  51.  
  52.     <dependency>
  53.       <groupId>javax.ejb</groupId>
  54.       <artifactId>ejb-api</artifactId>
  55.       <scope>provided</scope>
  56.     </dependency>
  57.  
  58.     <dependency>
  59.       <groupId>hsqldb</groupId>
  60.       <artifactId>hsqldb</artifactId>
  61.       <version>1.7.2</version>
  62.       <scope>test</scope>
  63.     </dependency>
  64.  
  65.   </dependencies>
  66.  
  67. </project>

The war/pom.xml file defines the dependencies for the WAR module. It depends on the ejb module.

XML:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project>
  3.   <parent>
  4.     <artifactId>mystuff</artifactId>
  5.     <groupId>mystuff</groupId>
  6.     <version>1.0</version>
  7.   </parent>
  8.   <modelVersion>4.0.0</modelVersion>
  9.  
  10.   <groupId>mystuff</groupId>
  11.   <artifactId>war</artifactId>
  12.   <name>mystuff - web</name>
  13.   <version>1.0</version>
  14.   <packaging>war</packaging>
  15.   <url>http://maven.apache.org</url>
  16.  
  17.   <build>
  18.     <finalName>war</finalName>
  19.   </build>
  20.  
  21.   <dependencies>
  22.  
  23.     <dependency>
  24.       <groupId>mystuff</groupId>
  25.       <artifactId>ejb</artifactId>
  26.       <version>1.0</version>
  27.       <scope>provided</scope>
  28.       <type>ejb</type>
  29.     </dependency>
  30.  
  31.    <!-- The following 4 dependencies are included in the WEB-INF/lib of the war -->
  32.  
  33.     <dependency>
  34.       <groupId>org.jboss.seam</groupId>
  35.       <artifactId>jboss-seam-ui</artifactId>
  36.     </dependency>
  37.  
  38.     <dependency>
  39.       <groupId>org.jboss.seam</groupId>
  40.       <artifactId>jboss-seam-debug</artifactId>
  41.     </dependency>
  42.  
  43.     <dependency>
  44.       <groupId>com.sun.facelets</groupId>
  45.       <artifactId>jsf-facelets</artifactId>
  46.     </dependency>
  47.  
  48.     <dependency>
  49.       <groupId>org.richfaces.ui</groupId>
  50.       <artifactId>richfaces-ui</artifactId>
  51.     </dependency>
  52.  
  53.     <!-- The "provided" dependencies are only need for compilation -->
  54.  
  55.     <dependency>
  56.       <groupId>javax.servlet</groupId>
  57.       <artifactId>servlet-api</artifactId>
  58.       <scope>provided</scope>
  59.     </dependency>
  60.  
  61.     <dependency>
  62.       <groupId>org.jboss.seam</groupId>
  63.       <artifactId>jboss-seam</artifactId>
  64.       <scope>provided</scope>
  65.     </dependency>
  66.  
  67.     <dependency>
  68.       <groupId>javax.faces</groupId>
  69.       <artifactId>jsf-api</artifactId>
  70.       <scope>provided</scope>
  71.     </dependency>
  72.  
  73.     <dependency>
  74.       <groupId>javax.faces</groupId>
  75.       <artifactId>jsf-impl</artifactId>
  76.       <scope>provided</scope>
  77.     </dependency>
  78.  
  79.     <dependency>
  80.       <groupId>org.hibernate</groupId>
  81.       <artifactId>hibernate-validator</artifactId>
  82.       <scope>provided</scope>
  83.     </dependency>