Setting up a development environment for JAX-RS applications

Before you start developing Java API for RESTful Web Services (JAX-RS) applications, you must set up your development environment by adding the JAX-RS libraries on the classpath.

Before you begin

Before you can set up a development environment for JAX-RS applications within the application server, you must install the Feature Pack for Web 2.0 for WebSphere® Application Server. For detailed information about installing the application server, read about installing your application server environment.

To develop JAX-RS applications, the JAX-RS libraries must be added to the classpath definition. See the information for your assembly tools to understand how to include libraries on the classpath for the JAX-RS application.

About this task

In the Feature Pack for Web 2.0, the JAX-RS implementation is packaged as a set of library Java archive (JAR) files. Before you begin compiling with the JAX-RS implementation, ensure that the JAX-RS libraries are included in the classpath.

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/web2mobilefep_1.1/optionalLibraries/jaxrs_1.X directory.
  2. Add the following libraries to the classpath definition:
    • 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 add a was.policy file to your application.

    The was.policy file is embedded in the META-INF/was.policy enterprise archive (.EAR) file. This file is located in the profile_root/config/cells/cell_name/applications/ear_file_name/deployments/application_name/META-INF/was.policy directory.

    The was.policy file must include 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. Compile the Web application with the JAX-RS libraries in the classpath.

Results

The JAX-RS libraries are now included in the classpath; you can now successfully compile the JAX-RS application.

What to do next

Develop your JAX-RS application and configure the web.xml file for the JAX-RS servlet.



In this information ...


Related concepts
Related reference

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 Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Sep 6, 2012 5:50:55 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v610webmob&product=was-nd-mp&topic=twbs_jaxrs_devenv
File name: twbs_jaxrs_devenv.html