Liferay Jersey Integration

Liferay Jersey Integration  tutorial will drive you on how to create web services using jersey framework. By default, Liferay provides axis engine framework for SOAP and JSON web services with Service Builder, that  generates local  service and remote service layers,  but still it has some limitations. Liferay with jersey offers very simple and easy implementation of web services.

Click here to access REST Tutorials with Jersey and Spring will give complete list of tutorials for beginners.

Liferay Remote web services limitations:

  • Liferay JSON web services allows only param request only. i.e you need to send whole data as request parameters and does not support JSON Object payload type.
  • Lifeary JSON web services allows only Service Builder entity to expose outside, what if you want expose custom entity as JSON?

Liferay Jersey web services limitations:

  • Need of Custom security implementation. This can be overcome with simple filter implementation
  • Liferay implicit functions and objects such as companyId and permission checker and all.

Let’s jump into Liferay Jersey rest tutorial and Download source code from here.

  1. Create  portlet plugin project to hold all Web services
    • Liferay Jersey Integration

        Liferay Jersey Rest webserviees
  2. Download jersey-bundle-1.19.jar and jackson-all-1.9.0.jar.   copy both of them in to lib folder
  3. Configure Jersey servlet in web.xml
    • <servlet>
  4.  Create package with below structure

    liferay rest webservices tutorial
    Liferay Rest Tutorial
  5. In Jersey init parameter, configure “” to controller path “”
  6. Set com.sun.jersey.api.json.POJOMappingFeature to true in init parameters  to enable  auto marshalling and unmarshalling of POJO’s to JSON or XML.
  7. Create a controller class that annotated with @Path and here you can see  ProductController class
    • @Path(value="/product")
      public class ProductController {
       public Response getProductDetails(){
       ProductModal pr = new ProductModal();
       System.out.println("ehits ");
       return Response.status(200).entity(pr).build();
       public Response addProduct(ProductModal pr){
       StatusModal st = new StatusModal();
       st.setMessage("Product Created Successfully");
       return Response.status(200).entity(st).build();
  8. Create POJO modal that need to annotate with @XmlRootElement to auto marshalling and unmarshalling of Java POJO to  JSON
  9. If application requires to produce both XML and JSON then update @Produces with XML media type as shown below
    1.  @GET
  10. Create Modal Object that need to annotate with @XmlRootElement
  11.  Finally deploy the portlet and access below URL
    1. Request URI :  http://localhost:8080/liferay-jersy-portlet/rest/product/getProductDetails
    2. XML Response:
    3. JSON Response:



Download the liferay jersey rest source code from here.

Hope this helps.

2 thoughts on “liferay jersey integration”
  1. This example is not getting deployed in Weblogic 12.

    getting below error while deploying via admin console:

    Message icon – Error Unable to access the selected application.
    Message icon – Error javax.servlet.Filter
    Message icon – Error javax.servlet.Filter
    Message icon – Error javax.servlet.Filter

Leave a Reply

Your email address will not be published. Required fields are marked *