Help

I'm a JBoss core developer at Red Hat, and the AeroGear project lead. I previously lead the RichFaces project, and have been involved in many other open source projects such as Seam, and JBoss AS. I'm passionate about promoting open source, community, and standards. I server as a W3C representative for Red Hat, and have been part of multiple Java Community Process (JCP) specifications, currently on the JSON API expert group. I have been architecting and developing enterprise applications and projects for over fourteen years, specializing in mobile device integration, web tier frameworks, UI design, and integration.

Location: Upstate New York USA
Occupation: JBoss core developer at Red Hat Inc.
Archive
20. Feb 2009, 22:11 CET, by Jay Balunas

Have you ever found yourself frustrated with a ClassNotFoundException? Would you like to know what libraries are in your project and what they depend on? Would you like to get a full report on this stuff every time you run your ant build? If so you need to take a look at the new JBoss Tattletale project!

JBoss Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on.

The tool will provide you with reports that can help you

  • Identify dependencies between JAR files
  • Find missing classes from the classpath
  • Spot if a class is located in multiple JAR files
  • Spot if the same JAR file is located in multiple locations
  • Identify JAR file versions
  • With a list of what each JAR file requires and provides
  • Verify the SerialVersionUID of a class

JBoss Tattletale will recursive scan a directory for JAR files and generate linked and formatted HTML reports.

JBoss Tattletale is licensed under GNU Lesser General Public License (LGPL) version 2.1 or later.

We hope that JBoss Tattletale will help you in your development tasks !

[Download] [Jira] [Forum] [SVN]

04. Nov 2008, 23:28 CET, by Jay Balunas

The Seam 2.1.0.SP1 release included a new reference guide chapter describing Seam integration with GlassFish v2. As with most container integration the bulk of the work is reconciling library differences, datasources and deployment descriptor changes. Glassfish is no different in that regard, however it is much easier to integrate and work with GlassFish than some of the other containers that I written about.

To demonstrate the ease of integration with GlassFish I'll show you how to deploy 2 different Seam examples, and migrate a seam-gen application one in one blog - and it won't even be that long - well not too long ;-)

GlasshFish Version and Setup

For this blog I used GlassFish v2ur4-b04 on a linux machine with JDK6. The instructions for installing GlassFish are at the bottom of the download page and are pretty straightforward. I'll assume that you have it installed and have created a domain as explained on the download page.

Note: all of the examples below require the embedded javaDB database that ships with GlassFish to be started. To start and stop the database execute:

$ asadmin start-database
$ asadmin stop-database

The jee5/booking Example

This example is based on the Seam Booking example and showcases how to build Java EE 5 compliant Seam application. To build and deploy it follow these steps.

  1. Navigate to the $SEAM_HOME/examples/jee5/booking directory
  2. Execute ant
  3. The example will build the ear file into the $SEAM_HOME/examples/jee5/booking/dist directory.
  4. Use the GlassFish Admin Console to deploy jboss-seam-jee5.ear as an Enterprise Application with all the default settings.
  5. Navigate to http://localhost:8080/seam-jee5/ and check out the example.

Thats it, nothing else is needed.

The jpa Example

This is the Hotel Booking example implemented with Seam POJOs and Hibernate JPA. Building and deploying this example is nearly the same as the jee5/booking example.

  1. Navigate to the $SEAM_HOME/examples/jpa directory
  2. Execute ant glassfish
  3. The example will build the war file into the $SEAM_HOME/examples/jpa/dist-glassfish directory.
  4. Use the GlassFish Admin Console to deploy jboss-seam-jpa.war as a Web Application with all the default settings.
  5. Navigate to http://localhost:8080/jboss-seam-jpa/ and check out the example.

These examples were quite easy and straightforward to build and deploy. This is partially because they were built with GlassFish integration in mind. You might be asking what actual changes are needed to deploy to GlassFish. The next section will cover that exact thing.

Migrating a seam-gen Project to GlassFish

The Seam framework uses seam-gen as a tool for developers to quickly get an application up and running, and provides a foundation to add your own functionality. seam-gen creates applications that deploy to JBoss AS. This section will detail what to change so you can deploy into GlassFish.

Initial Project Setup

First step is to get seam-gen to setup and create the base project. In the $SEAM_HOME directory execute ./seam setup. This will launch a command line questionnaire about your application. Set the JBoss home and workspace as you wish. Set the project name to seamgen_example, use RichFaces ( instead of IceFaces ), and we want to make an ear project. For all the other entries you can use the default values.

Then have seam-gen create the project by executing ./seam new-project. Then navigate to the new project for the rest of the steps.

Configuration File Changes

Below are the various changes needed to the default configuration files.

resources/META-INF/persistence-dev.xml

  • Change the jta-data-source to be jdbc/__default
  • Replace all of the persistence properties with the following:
<property name="hibernate.dialect" value="GlassFishDerbyDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>

resources/GlassFishDerbyDialect.class

We need to copy this file from the jpa example to work around an issue with Derby (javaDB) packaged with GlassFish. From the seamgen_example project base execute the following.

cp $SEAM_HOME/examples/jpa/resources-glassfish/WEB-INF/classes/GlassFishDerbyDialect.class ./resources

resources/WEB-INF/components.xml

  • We want GlassFish to manage our transactions so we need to add <transaction:ejb-transaction /> and its namespace xmlns:transaction="http://jboss.com/products/seam/transaction" at the top of the file.
  • Change the jndi-pattern to java:comp/env/seamgen_example/#{ejbName}

resources/WEB-INF/web.xml

We need to add the following to the bottom of web.xml so that GlassFish binds the EJBs correctly.

  <ejb-local-ref>
    <ejb-ref-name>seamgen_example/EjbSynchronizations</ejb-ref-name>  
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home></local-home>
    <local>org.jboss.seam.transaction.LocalEjbSynchronizations</local>
  </ejb-local-ref>

resources/META-INF/application.xml

Our base application does not have any of its own EJBs yet, and GlassFish does not like it when an application declares an EJB module that contains no EJBs. So we need to remove the following:

 <module>
    <ejb>seamgen_example.jar</ejb>
 </module>

Updating the Build File

Now all that is left is updating the build.xml file for the seamgen_example project.

Adding GlassFishDerbyDialect.class to the Build

To do this locate the jar target and add the <include name="GlassFishDerbyDialect.class" /> where it is show below.

 <target name="jar" depends="compile,copyclasses" description="Build the distribution .jar file">
   <copy todir="${jar.dir}">
      <fileset dir="${basedir}/resources">
         <include name="seam.properties" />
         <include name="*.drl" />
         <include name="GlassFishDerbyDialect.class" />
      </fileset> 
   </copy>
  ...

Adding Dependent Libraries

Locate the ear target and add the following <include .../> elements into the <copy todir="${ear.dir}/lib"> so that the <fileset dir="${lib.dir}"> looks like this:

 <fileset dir="${lib.dir}">
   <includesfile name="deployed-jars-ear.list" />
   
   <!-- Hibernate and deps -->
   <include name="hibernate.jar"/>
   <include name="hibernate-commons-annotations.jar"/>
   <include name="hibernate-annotations.jar"/>
   <include name="hibernate-entitymanager.jar"/>
   <include name="hibernate-validator.jar"/>
   <include name="jboss-common-core.jar" />
   
   <!-- 3rd party and supporting jars -->
   <include name="javassist.jar" />
   <include name="dom4j.jar" />
   <include name="concurrent.jar" />
   <include name="cglib.jar" />
   <include name="asm.jar" />
   <include name="antlr.jar" />
   <include name="commons-logging.jar" />
   <include name="commons-collections.jar" />
 </fileset>

Build and Deploy

All that is left at this point is to build and deploy the application.

To build it all you have to do is run ant archive in the seamgen_example directory. This will create a seamgen_example/dist directory with the seamgen_example.ear file in it.

Deploy this example the same way we deployed the jee5/booking example.

Check out the fruits of your labor at http://localhost:8080/seamgen_example.

Wrap up

So this blog was a little longer than expected but we did deploy 3 applications not just 1 like the other interoperability blogs ;-) These should give you a good starting point for your Seam own applications on GlassFish.

For more details on installing GlassFish, and some of changes we made please see the Seam on GlassFish application server reference guide chapter.

Update: Some changes and fix's were recently made to the reference guide chapter. This blog contains the latest information, and updates will be in the 2.1.1.CR1 release of seam.

The 2.1.0.SP1 release of Seam contained many features and updates, one of which is an updated Weblogic integration reference guide chapter

This update includes the latest information on integration with the new Weblogic Application server 10.3. Many Seam/Weblogic users were waiting expectantly for this release of Weblogic. There were several issues relating to EJB 3 support with wls 10.0.MP1, that were scheduled to be fixed in the 10.3 release.

The Good News

The good news is that the original varargs issue is fixed in this release and does not require a patch. For those of you not familiar with this Weblogic 10.0.MP1 ( and other earlier releases ) would fail to compile any EJB's that used variable arguments. For some reason weblogic's compiler would mistake this as if the method had a transient modifier, which being a method would fail to compile.

The Bad News

The bad news is that the fix for the other EJB3 issue found with 10.0.MP1 does not appear to have made the release. I can only image that with the BEA's purchase by Oracle a few of these changes were lost. Several Seam users have seen it, and my own investigation confirmed it.

This issue causes certain EJB methods to be incorrectly left out of Weblogic's generated internal stub classes. This occurs on the same files effected by the varargs issue, so I'm assuming it is related to their fix. This results in the following error messages during deployment.

<<Error> <EJB> <BEA-012036> <Compiling generated EJB classes produced the following Java compiler error message:
<Compilation Error> TimerServiceDispatcher_qzt5w2_Impl.java: The type TimerServiceDispatcher_qzt5w2_Impl must implement the inherited abstract method TimerServiceDispatcher_qzt5w2_Intf.scheduleTimedEvent(String, Schedule, Object[])
<Compilation Error> TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java: Type mismatch: cannot convert from Object to Timer
<Compilation Error> TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java: Type mismatch: cannot convert from Object to Timer> 
<Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1223409267344' for task '0'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(jboss-seam.jar)

The Workaround

Since the EJB3 issues persist with 10.3 you have a couple of options for using EJB 3 with Weblogic and Seam.

  • Use the jboss-seam-wls-compatible.jar in place of the jboss-seam.jar as described in the Seam reference guide here : EJB3 Issues with WebLogic
  • Contact BEA's customer support and request a patch. There was a patch available for 10.0.MP1 release, and I would hope it is also available for 10.3

As always we well try to keep up to date with this issue, and when a patch or release is made public we'll review and update our documentation.

19. Jun 2008, 23:27 CET, by Jay Balunas

There has been a post or two regarding Seam and RESTeasy in the Seam forums, and the RESTeasy mailing list so I thought I would share my opinion as to where these technologies could fit together. I have been thinking about this since talking with Bill Burke at his JUG talk on RESTeasy.

For those who are not familiar RESTeasy it is an implementation of the JAX-RS specification that Bill Burke is working on. See RESTeasy project page for more info.

Some people get hung up on how these two technologies can integrate because Seam is by nature and definition a stateful framework, and REST by definition should be stateless. The question is not do they integrate, but can they co-exist?

I see two primary ways for Seam and RESTeasy to work together :

  • Multiple ways to access/manipulate the same server side component.

If I have a Seam component (EJB or POJO does not matter) and I want to have it accessible via a restful call. I should be able to put the correct annotations on it from the JAX-RS spec, and have RESTeasy manage restful access. This EJB/POJO would effectively be both a seam component, and a restful service.

  • Seam using restful calls as a result of a user action, or to pull data

Take for example a Seam application that displays TV schedules for any zip code in the country, and lets users create a calender of what shows they want to watch. Seam internally could make restful calls to an existing service for all of the TV schedule information. When the user selects a show the seam application captures the information from the service, and processes and stores that information locally using EJBs, POJOs, or whatever.

I suppose providing an easy way for Seam to access a remote restful service as a seam component would be useful. It could treat it like a stateless session bean, or something like that. Users today need to write the plumbing to make the restful call, and manipulate the return. I'll have to think on that some more :-)

My $.02

31. May 2008, 03:09 CET, by Jay Balunas

The latest release of Seam 2.0.2.SP1 includes a completely updated reference guide chapter for deploying Seam on BEA's Weblogic . The primary focus was on working around several issues with Weblogic and EJB3 support.

We will explain and demonstrate how to get the Seam jee5/booking example installed and running on Weblogic 10.0.MP1. This example demonstrates the use of Seam in a Java EE 5 environment using EJB3 with transaction and persistence context management handled by Weblogic.

What you need

First step we need to install Weblogic 10.0.MP1, and create a domain in Development Mode. You can use either the Sun JDK or the JRockit JDK it does not matter to this example.

For this example we'll refer to the seam distribution directory as $SEAM_DIST, BEA home as $BEA_HOME, and the domain home as $DOMAIN_HOME.

The Weblogic varargs issue

For several release of Weblogic you could not deploy an EJB that used variable arguments in its methods. Weblogic's internal EJB compiler confuses variable arguments as if it was a transient modifier. Seam uses variable arguments in one of its internal EJB's TimerServiceDispatcher, so when deployed this produces an error like this:

java.io.IOException: Compiler failed executable.exec: /jboss/apps/bea/wlserver_10.0/user_projects/domains/seam_examples/servers/AdminServer/cache/EJBCompilerCache/5yo5dk9ti3yo/org/jboss/seam/async/
TimerServiceDispatcher_qzt5w2_LocalTimerServiceDispatcherImpl.java:194: modifier transient not allowed here
  public transient javax.ejb.Timer scheduleAsynchronousEvent(java.lang.String arg0,java.lang.Object[] arg1)

To work around this issue there are 2 options:

Option 1) Apply the CR327275 patch, but...

BEA has released a patch that addresses the variable arguments issue. It is named CR327275 and can be requested from BEA through their support organization.

Unfortunately an additional issue that this patch either causes, or exposes has been reported and verified by BEA (CR363182). This issue has to do with certain EJB methods incorrectly left out of Weblogic's generated internal stub classes. Some users have reported that this does not effect them - see this 2.0.2.GA release comment for details.

Option 2) Don't deploy TimerServiceDispatcher EJB

Starting with Seam 2.0.2.CR2 a special Weblogic specific jar has been packaged that does not contain the TimerServiceDispatcher . This is the only Seam EJB that uses variable arguments.

$SEAM_DIST/lib/interop/jboss-seam-wls-compatible.jar

To use this jar simply rename jboss-seam-wls-compatible.jar to jboss-seam.jar and replace the original in your applications EAR file.

We will be using this approach for the jee5/booking example here.

Weblogic's JSF support

Weblogic requires its own JSF 1.2 libraries be deployed when using an EAR based application. I suspect this has to do with classloader visibility while processing EARs and deploying EJBs.

Out of the box Weblogic does not come with its JSF libraries deployed, an like other parts of Weblogic it almost worked as expected.

  1. Start the Server and launch the Weblogic administration console.
  2. Deploy $BEA_HOME/wlserver_10.0/common/deployable-libraries/jsf-1.2.war
  3. Make sure Install this deployment as a library is selected
  4. On the Settings for jsf(1.2,1.2.3.1) page set the Deployment Order to 99 so that it is deployed before autodeployed applications.
  5. Don't forget to activate your changes

Later you will see how to get your application to reference this shared library.

That should be it but you will get errors like the one below when deploying your application.

User defined listener com.sun.faces.config.ConfigureListener failed: java.lang.NullPointerException

Again this is most likely due to classloader visibility issues.. To work around this you need to have the jsf-api.jar from inside the jsf-1.2.war in the $DOMAIN_HOME/lib directory. While you are there you might as well copy in the $SEAM_DIST/lib/hsqldb.jar for the next section. You will need to stop and start your server for these to take effect.

Setting up the example data source

Configuring the seam-jee5-ds is pretty straight forward, and we can do it all through the admin console.

  1. If you have not already, you will need to copy the $SEAM_DIST/lib/hsqldb.jar into the $DOMAIN_HOME/lib directory and restart the server.
  2. Launch the admin console and navigate to $DOMAIN_NAME -> Services -> JDBC -> Data Sources
  3. Create a new data source with the values below.
  • Name = seam-jee5-ds
  • JNDI Name = seam-jee5-ds
  • Set database type to other
  • Database name = hsqldb
  • Host Name = 127.0.0.1
  • Port = 9001
  • Username = sa
  • Driver class = org.hsqldb.jdbc.Driver
  • URL = jdbc:hsqldb:.

Then just choose your domain for the data source and activate your changes.

The example/jee5/booking example

Now Weblogic is all set up we need to make some adjustments to the jee5/booking example. These are mainly configuration file and build script changes.

Configuration File changes

Paths are assumed from the $SEAM_DIST/examples/jee5/booking directory

resources/META-INF/persistence.xml

  • Comment out glassfish properties
  • Set <jta-data-source>seam-jee5-ds</jta-data-source>
  • Add the following properties:
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>

resources/WEB-INF/web.xml

  • Because the JSF jars are not going to be packaged in the WAR we need to add:
<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

resources/META-INF/weblogic-application.xml

You must create this file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<weblogic-application>
    <library-ref>
        <library-name>jsf</library-name>
        <specification-version>1.2</specification-version>
        <implementation-version>1.2</implementation-version>
        <exact-match>false</exact-match>
    </library-ref>
    <prefer-application-packages>
        <package-name>antlr.*</package-name>
    </prefer-application-packages>
</weblogic-application>

This allows the EAR to reference the JSF libraries installed above, and also manages a dependency conflict with antlr.

resources/WEB-INF/weblogic.xml

You must create this file:

<?xml version="1.0" encoding="UTF-8"?>

<weblogic-web-app> 
<library-ref>
    <library-name>jsf</library-name>
    <specification-version>1.2</specification-version>
    <implementation-version>1.2</implementation-version>
    <exact-match>false</exact-match>
  </library-ref>
</weblogic-web-app>

This allows the WAR to reference the JSF libraries installed above and yes, it is needed in both places ;-)

resources/META-INF/ejb-jar.xml

Update the <assembly-descriptor> to look like the following:

<assembly-descriptor>
   <interceptor-binding> 
      <ejb-name>AuthenticatorAction</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
   <interceptor-binding> 
      <ejb-name>BookingListAction</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
   <interceptor-binding> 
      <ejb-name>RegisterAction</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
   <interceptor-binding> 
      <ejb-name>ChangePasswordAction</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
   <interceptor-binding> 
      <ejb-name>HotelBookingAction</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
   <interceptor-binding> 
      <ejb-name>HotelSearchingAction</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
   <interceptor-binding> 
      <ejb-name>EjbSynchronizations</ejb-name>
      <interceptor-class >org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
   </interceptor-binding>
</assembly-descriptor>

The changes to this file were the real challenge with Weblogic (to be polite about it). Unlike the other application servers tested Weblogic is only using a single instance of the sessionBeanInterceptor for all session beans if <ejb-name>*</ejb-name> is used. By defining a separate interceptor for each bean we force Weblogic to create a distinct instance for each session bean.

Note: There was a deployment descriptor that should have changed this behavior, but it did not have any effect.

Dependencies and getting them packaged

There are just a couple of changes needed the build file so that the new files above are packaged, and some extra jars are included.

build.xml

  • Add the bits below:
<!-- jars to go in the war's lib -->
<fileset id="war.lib.extras" dir="${seam.dir}"> 
   <include name="lib/richfaces-api.jar" />
</fileset>

<!-- Resources to go in the ear -->
<fileset id="ear.resources" dir="${resources.dir}">
   <include name="META-INF/application.xml" />
   <include name="META-INF/weblogic-application.xml" />
   <include name="META-INF/*-service.xml" />
   <include name="META-INF/*-xmbean.xml" />
   <include name="treecache.xml" />
   <include name="*.jpdl.xml" />
   <exclude name=".gpd.*" />
   <include name="*.cfg.xml" />
   <include name="*.xsd" />
</fileset>
  • Search for ear.lib.extras fileset and add these:
<include name="examples/wiki/lib/jboss-archive-browsing.jar" />
<include name="lib/concurrent.jar" />

$SEAM_DIST/lib/interop/jboss-seam-wls-compatible.jar

The last item to deal with is to replace the jboss-seam.jar with the jboss-seam-wls-compatible.jar. There are really two options.

  • Backup the original $SEAM_DIST/lib/jboss-seam.jar and rename and replace with jboss-seam-wls-compatible.jar
  • Modify the jboss-seam-jee5.ear after the build and replace the jar there.

Deploying and viewing your application

Now all we have to do build the application and deploy it.

If you chose the first option for handling the jboss-seam-wls-compatible.jar then all we need to do is execute:

$SEAM_DIST/examples/jee5/booking/ant

Then because we created our Weblogic domain in development mode we deploy it to the autodeploy directory.

cp $SEAM_DIST/examples/jee5/booking/dist/jboss-seam-jee5.ear $DOMAIN_HOME/autodeploy

Now point your browser at http://localhost:7001/seam-jee5/

If you see classdef or classloader issues during deployment or redeployment try removing the EAR from the autodeploy directory, restarting the server, and redeploying. Weblogic sometimes has classloader issues when applications are redeployed.

Would you like to know more?

See the reference guide chapter: Seam on BEA's Weblogic with details on this example and other Seam applications on Weblogic.

Showing 51 to 55 of 58 blog entries