Assembling JAX-RS Web applications

After you develop the Java™ class files for your Java API for RESTful Web Services (JAX-RS) Web application and edit the web.xml file to enable the JAX-RS servlet, you must assemble the application.

Before you begin

Identify the assembly tool to use to assemble your application. The Web application is assembled into a Web archive (WAR) package. You can assemble the WAR package into an enterprise archive (EAR) package if required.

Before assembling the Web application, you must edit the web.xml file to enable the JAX-RS servlet.

About this task

You must add the JAX-RS libraries to the Web application in the WEB-INF/lib directory before you assemble the Web application.

Procedure

  1. Locate the JAX-RS implementation in the application server installation.

    The default location of the JAX-RS installation is the app_server_root/web2fep/optionalLibraries/jaxrs_1.X directory.

  2. Add the following libraries to the WEB-INF/lib directory of the Web application:
    • jsr311-api.jar
    • commons-lang.jar
    • slf4j-api.jar
    • slf4j-jdk14.jar
    • ibm-wink-jaxrs.jar
    If you are using a WebSphere Application Server Version 6.1 installation that does not have JAXB libraries installed, you must include the following JAXB JAR file:
    • ibm-jaxb-2.1.0.jar
    Avoid trouble Avoid trouble: If you are migrating a JAX-RS application from WebSphere Application Server Version 6.1 to a WebSphere Application Server Version 7.0 install or you are migrating to a version of the application server with a feature pack installed that includes JAXB libraries, you must not include the JAXB JAR file. gotcha
  3. If Java 2 Security is enabled, you must package your WAR file into an EAR file, and add a was.policy file to your application. Add the was.policy file to your application with the following permissions:
    grant codeBase "file:${application}" {
    
    permission java.io.FilePermission "META-INF/wink-default.properties", "read";
    
    permission java.io.FilePermission "META-INF/wink-alternate-shortcuts.properties", "read";
    
    permission java.io.FilePermission "META-INF/core/wink-providers", "read";
    
    permission java.io.FilePermission "META-INF/server/wink-providers", "read";
    
    permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
    
    }; 
  4. Create the WAR package using assembly tools.

Results

A WAR package is created that contains the Web application. If needed, you can add the WAR package to an EAR package. The application server can deploy either the WAR or EAR packages.

What to do next

Deploy the Web application.




In this information ...


Related concepts

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic    

Terms of Use | Feedback

Last updated: Feb 19, 2011 8:24:38 AM CST
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v610web&product=was-nd-mp&topic=twbs_jaxrs_assemble
File name: twbs_jaxrs_assemble.html