The JAX-RS web service needs to reside in a project with
the JAX-RS facet enabled.
- In the Java EE perspective, right-click your enterprise application project
and select to open the web project wizard.
- In the Name field, type a name
for your new web project. For
this tutorial, use JAXRS.
- In the Project Templates
section, select the type of web template you want to use: For
this tutorial, select Simple.
Option |
Description |
Dojo Toolkit |
Configures the project to have Dojo capabilities. The Dojo
resources can be in the project itself, a separate project, or a
remote location accessible via HTTP. |
JavaServer Faces |
Enables the project to be deployed with JSF capabilities.
Configuration is provided for either JSP or Facelets. |
REST Services |
A project configured for REST Services based on JAX-RS |
Simple |
This creates a basic web project. |
- In the Programming
Model section, select the programming model you want to use: For
this tutorial, select Java EE.
- Client-side only (HTML, JavaScript,...)
- Java EE
- OSGi
- Click Next to configure
your new web project.
- On the deployment
page, from the list of available configuration options, click Deployment to open the Deployment configuration page.
- In the Target runtime field, select the
v7 or v8 WebSphere Application Server that you installed earlier in
the tutorial.
- In the Web module version field, accept
the default (which is automatically selected based on which WebSphere
Application Server you selected).
- In the EAR Membership field, select Add
project to an EAR, and ensure that JAXRSEAR is
the EAR project name.
- Under the Deployment section, select Change Features.
On the Project Facets page, select JAX-RS (REST Web Services),
version 1.1, and click OK.
- From the list of available
configuration options, click Java to open the Java configuration page.
- In the Source folders on build path field,
accept the default src directory, or click Add Folder, Edit... or Remove to specify a folder for your source files.
- In the Default output folder: field, specify
a folder for your output files or accept the default value (WebContent\WEB-INF\classes).
Important: If you choose a folder other
than WebContent\WEB-INF\classes for your default output folder, the
problems view will report a warning:
The default
for single rootedness problems is set to warning. To change this setting,
select . Click the
... settings field,
and select
- Error
- Warning
- Ignore
- From the list of available configuration options, click REST
Services to open the REST Services configuration page.
In the JAX-RS Implementation Library field,
select IBM WebSphere Application Server v<x> JAX-RS
Library. If you are using a version of WebSphere Application
Server earlier than v8, check Include library with this
application and select to include it as a Shared
Library. Click Udate Deployment Descriptor.
Ensure that the following values appear:
- In the JAX-RS servlet name: field, ensure
that JAX-RS Servlet appears.
- In the JAX-RS servlet class name: field,
ensure that com.ibm.websphere.jaxrs.server.IBMRestServlet appears.
- In the URL mapping patterns: field, ensure
that /jaxrs/* appears.
The JAX-RS libraries for each WebSphere Test Environment
you have installed will be listed in this drop-down box. If you want
to use a non-WebSphere library, it can be imported using the User
Libraries preference page. If you select User Library, you can launch
the User Libraries preference page and add a library. Once a project
has been created, you can change the library on the page.
- From the list of available configuration
options, click Web Module.. On the Web Module
configuration page,
- In the Context
root field, type the name of your web project root, or
accept the default (which is the name of your web project).
- In the Content directory field, type the name
of your content directory, or accept the default (WebContent).
- Select Generate web.xml deployment descriptor if you want to
create a deployment descriptor. You can also add a deployment descriptor
to your web module later.You
need to use a web.xml to configure security
constraints and other behavior.
- Click Finish.
The facet adds the library, servlet information, and support
for JAX-RS annotations processing and JAX-RS quick-fixes.
Now you
are ready to begin the next module: Creating and testing the web service.