SeamFramework.orgCommunity Documentation

Chapter 60. Installation

60.1. Basics
60.2. Transitive dependencies
60.3. Registering JAX-RS components explicitly
60.4. Servlet container support

The Seam REST module runs only on Java EE 6 compliant servers such as JBoss Application Server or GlassFish .

To use the Seam REST module, add seam-rest and seam-rest-api jars into the web application. If using Maven, add the following dependency into the web application's pom.xml configuration file.


Besides, Seam REST has several transitive dependencies (which are added automatically when using maven). Refer to Section 65.1, “Transitive Dependencies” for more details.

The Seam REST module registers SeamExceptionMapper to hook into the exception processing mechanism of JAX-RS and TemplatingMessageBodyWriter to provide templating support.

These components are registered by default if classpath scanning of JAX-RS resources and providers is enabled (an empty javax.ws.rs.core.Application subclass is provided).

@ApplicationPath("/api/*")

public class MyApplication extends Application {}

Otherwise, if the Application's getClasses() method is overridden to select resources and providers explicitly add SeamExceptionMapper and TemplatingMessageBodyWriter .

@ApplicationPath("/api/*")

public class MyApplication extends Application
{
   @Override
   public Set<Class<?>> getClasses()
   {
      Set<Class<?>> classes = new HashSet<Class<?>>();
      ...
      ...
      ...
      classes.add(SeamExceptionMapper.class);
      classes.add(TemplatingMessageBodyWriter.class);
      return classes;
   }
}

Seam REST can be used with plain Servlet containers such as Apache Tomcat 7. Firstly, we need to enhance the Servlet container capabilities. This is done by bundling Weld and RESTEasy within the application and configuring them. See the jaxrs-exceptions example and its tomcat build profile for more details.

In a EE6-compliant environment, Seam REST would be bootstrapped by a Servlet listener. However, weld-servlet does not support CDI injection into Servlet listeners. Therefore, add the following line to your application's web.xml file to bootstrap Seam REST using Servlet.


<servlet>
        <display-name>Servlet REST Listener Startup</display-name>
        <servlet-class>org.jboss.seam.rest.SeamRestStartupListener</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>