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
- 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.
- 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:
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
- 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";
};
- 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.