Building and Running JAX-RS Samples
Using Maven
Apache Maven 3 is recommended to build the samples.
Follow the steps given below before you build and run the sample.
Remove the following parent POM reference from the sample's pom.xml file, which is stored in theÂ
<PRODUCT_HOME>\samples\
 directory.<parent> <groupId>org.wso2.appserver</groupId> <artifactId>wso2appserver-samples-parent</artifactId> <version>5.2.1</version> </parent>
Note that this step is necessary because of a known issue, which will be fixed in AS 6.0.0.
As shown below, add the
<version>
and<groupid>
elements to thepom.xml
 file, after the parent element which you commented out in the first step.<groupId>org.wso2.appserver</groupId> <version>5.2.1</version>
To build and run the sample:
- Open the maven Â
pom.xml
 file, which is in the base directory of the sample (i.e., Â<PRODUCT_HOME>\samples\Jaxws-Jaxrs\<JAX-WS-Sample-Folder>
 ). To determine Â<JAX-RS-Sample>
, see JAX-RS Sample Folder. Build the demo and create a WAR file using the following command.
mvn clean install
Start the WSO2 Application Server by executing one of the following commands, whereÂ
<PRODUCT_HOME>
 is the directory where you installed the product distribution:OS Command On Windows <PRODUCT_HOME>\bin\wso2server.bat --run
On Linux/Solaris sh <PRODUCT_HOME>/bin/wso2server.sh
Deploy the generated WAR file on WSO2 AS with the related logs on the console.
mvn -Pdeploy
Run the client.
mvn -Pclient
If you wish to remove the target directory, run the following command:
mvn clean
Using Apache Ant
You need Apache Ant 1.6.2 or higher to build the samples.
To deploy the sample service on the server, run the following command from theÂ
<PRODUCT_HOME>\samples\Jaxws-Jaxrs\<JAX-RS-Sample-Folder>
directory (see JAX-RS Sample Folder).ant
- Start the application server and access its Management Console at https://localhost:9443/carbon.
- On the Main menu, under Services, click List.
The Deployed Services will appear. Click on the respective JAX-RS sample (e.g., jaxrs_starbucks_service).
Execute one of the following commands to run the client:
OS Command On Windows run-client.bat
On Linux/Solaris sh run-client.sh
Â
- Try the sample with different QoS options that appear on its dashboard.Â
For different options, run:
sh run-client.sh -help
Â
JAX-RS Sample Folder
Sample | JAX-RS Sample Folder |
---|---|
JAX-RS Basics | jaxrs_basic |
JAX-RS Advanced | jaxrs_starbucks_service |
JAX-RS Sample on Content Negotiation | jaxrs_content_negotiation |