FaqSeamSupport

Draft

How can I use Seam / Hibernate in a NetBeans project?

This document shows you the basic steps of how to add support for JBoss Seam to the IDE. This page collects information from various sources on how to configure the IDE so that you can use Seam / Hibernate in a NetBeans project.

NetBeans IDE does not come bundled with the JBoss Seam or Hibernate libraries, so you need to download the libraries and then create the required class libraries in the IDE. You then add the libraries to your project and then configure the project to use Seam.

For more detailed information, see the individual sources listed under References below.

Contents



Download JBoss Seam /Hibernate

The first thing you need to do is to download the required sources and extract them to your local machine:

  1. Download JBoss Seam from the JBoss Seam download site
  2. Download Hibernate from the Hibernate.org site

Set up the target server

You need to make sure that the necessary libraries are available on your target application server.

  • If you are deploying to the JBoss application server, you can access the Seam and Hibernate libraries that come bundled with the server.
  • If you are deploying to the Sun Java System Application Server, you need to add the Seam and Hibernate libraries to the
    lib
    directory of the application server and then restart the server.

If your target server is the Sun Java System Application Server

The Sun Java System Application Server does not come bundled with the Seam / Hibernate libraries so you need to manually add the libraries to the
lib
directory of the application server.
  1. Install the Sun Java System Application Server (if not already installed) and make sure the server is registered with the IDE.
  2. Copy the required Seam and Hibernate libraries to the
    lib
    directory of the application server installation.
  3. Restart the server.

After you add the libraries to the server, you can follow the steps to create the class libraries in the IDE and configure your project to use Seam and Hibernate.

You also need to add some Seam and Hibernate libraries to your application. You need to add the jar files
hibernate-all.jar
and {thirdparty-all} found in the lib directory of your Seam installation directory.
  1. Create a new class library (for example, JBossSeamAll).
  2. Set the Classpath to
    hibernate-all.jar
    and {thirdparty-all}.
  3. Right-click the Libraries node of the your project and add the JBossSeamAll library.



If your target server is the JBoss application server:

To develop and deploy an application to the JBoss application server, you need to first do the following:

  1. Download and install the JBoss application server. When you install JBoss, make sure you select the EJB3 option.
  2. Register the JBoss application server instance with the IDE.

After you register the server with the IDE, you can follow the steps to use Seam / Hibernate in your project.


create the class libraries in the IDE and configure your project to use Seam and Hibernate.


Using Seam / Hibernate in a NetBeans project

After you have have downloaded the source and set up your server, you need to add support for Seam.

What you do next depends on the target application server.

Deploying to the JBoss application server

If you are deploying to the JBoss application server, you have the following options:

  • If you want to create a new Seam project, you can install the Seam Generator plugin. After you install the plugin you can create a new Seam application project in the IDE. This allows you to use Seam technology without requiring additional configuration.
  • If you have a project and you want to use Seam, you need to create a Seam library in the IDE and then manually configure your project descriptor files to use Seam.


I want to create a new Seam application project in NetBeans IDE

If you want to create a new project and use Seam, the easiest way is to download the Seam Generator plugin and then install the plugin in the IDE. You may also want to download the facelets plugin while you are at the nbfaceletssupport site .

Installing the plugin module adds the following to the IDE:

  • A new Seam Generator application project type is added to the Enterprise category in the New Project wizard.
  • A new Seam Generator category is added to the New File wizard. The Seam category has templates for various Seam file types.


  1. download the Seam Generator plugin .
  2. Install the plugin org-netbeans-modules-web-nbseamgenintegration.nbm using the NetBeans Update Center (Tools > Update Center).
  3. Create a new Seam application project using the New Project wizard. In the New Project wizard, select the Seam Generator project from the Enterprise category.

note: When you create the new Seam application, you will need to specify the location of your Seam installation in the wizard. You should specify the location of the JBoss Seam (for example, /mydocs/jboss-seam-1.1.1.GA)


When you create the Seam application, the classpath is automatically set so that you can use Seam technologies when developing your project. You can see the Java sources classpath for the project in the project properties window. In the Files window of the IDE, you can expand the lib node to see the libraries for the project.

For an example of how to create a Seam application using the plugin, see http://www.michaelyuan.com/blog/2007/04/17/first-release-of-seam-plugin-for-netbeans/


I have a NetBeans project and I want to use Seam in my project

If you have a JSF/EJB 3.0 project that you want to develop using Seam, here are the basic steps to follow:

  1. Create a Seam library in the IDE
  2. Add the Seam library to the project
  3. Configure web.xml
  4. Configure faces-config.xml
  5. Add the Seam.properties file
  6. Configure ejb-jar.xml

The exact changes you need to make to the xml files will vary depending upon your project. You can now code your application and the Seam framework will be available.

Create a Seam library

Use the Library Manager to create a NetBeans library that contains the sources necessary to use Seam in the project. In the library Manager we will specify the classpath, sources and javadoc for the Seam library.

  1. Open the NetBeans Library Manager (Tools > Libraries) and click New Library.
  2. Name the library (e.g. SeamLib) and choose Class Library.
  3. Select the new SeamLib from the list of libraries and do the following:
  • Set the Classpath to jboss-seam.jar.
  • Set the Sources to the JBoss Seam src directory.
  • Set the Javadoc to the JBoss Seam doc directory.

You can now use SeamLib in any NetBeans project.


Add the Seam Library to Your Project

Now add the SeamLib to the project classpath by adding it to the project's library

  1. Expand the project node in the Projects window
  2. Right-click the Libraries node of your project and choose Add Library.
  3. Select the SeamLib library from the list and click Add Library.

You can expand the Libraries node or open the project properties window to see the libraries in the project.


Configure
web.xml
The changes you will need to make to configure
web.xml
will vary according to your project.
  1. Expand the Configuration Files node of your web module and open
    web.xml
    in the Source Editor
  2. Configure the
    web.xml


Configure
faces-config.xml
  1. Open faces-config.xml and add the following phase listener:
<faces-config ...


          <lifecycle>
              <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>          
          </lifecycle>
      </faces-config>


Add
Seam.properties
file

This file is required for Seam, but can be empty.

In an EJB Module, this file should be located in the
src/conf
directory

In a Web Module

  1. Open New File wizard


Unfortunately, the Seam framework expects to find this file in the root of the EJB jar file and not in the META-INF directory, so we have to create a custom Ant target to put it there.

  1. Switch to the Files tab and open Registration-EJBModule's build.xml.
  2. Add the following target:
     <target name="-pre-compile">
         <copy file="${meta.inf}/seam.properties" todir="${build.dir}/ear-module"/>
     </target> 


Configure ejb-jar.xml

  1. Add the following assembly descriptor to ejb-jar.xml:
        <assembly-descriptor>
           <interceptor-binding>
              <ejb-name>*</ejb-name>
              <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
           </interceptor-binding>
        </assembly-descriptor>
     The SeamInterceptor integrates Seam with the Session Beans.




References

Official Seam demo app for Glassfish (November 29th, 2006)

Seam (FCS) On GlassFish (July 25, 2006)

Running JBoss' Seam on GlassFish (June 20, 2006)

Develop web application with netbeans ,seam and Glassfish (August 15, 2006)

Using Hibernate with the Java Persistence API

HalloWorld using Seam with the IDE Netbeans 6.5 on Glassfish (Feb 27, 2009)



Support for Facelets in NetBeans IDE NetBeans Seam Generator Integration module

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo