Liferay Development

Liferay Consulting

Liferay Training

Your Trusted Liferay Solutions Partner

Tuesday, November 27, 2012

Expose Liferay Custom JSON web Services in Plug-in Environment

Download plugin portlet from following URL

Following is the step by step description of generating a custom liferay plugin service and exposing it as JSON Web Service.

STEP: 1 Create a liferay plugin project and create new service

Here is the sample service.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "">
<service-builder package-path="com.meera.json">

<entity name="Student" local-service="true" remote-service="true">
            <column name="studentId" type="long" primary="true" />
            <column name="studentName" type="String" />

Make sure remote-service=”true” in entity tag declaration.

STEP: 2  Build the service.
STEP: 3 write you custom method implementation in

public com.meera.json.model.Student getStudent(long studentId)
      throws com.liferay.portal.kernel.exception.PortalException,
            com.liferay.portal.kernel.exception.SystemException {
      return StudentLocalServiceUtil.getStudent(studentId);

Note: Here I am using existed method only don’t confuse. You can write your custom method implementation instead of my method.

STEP: 4 build the service using command ant build-service from your eclipse ant view

STEP: 5 Add the following <servlet> and <servlet-mapping> Entries to portlet’s  web.xml file

<servlet-name>JSON Web Service Servlet</servlet-name>
<servlet-name>JSON Web Service Servlet</servlet-name>
<servlet-name>JSON Web Service Servlet</servlet-name>

STEP: 6 deploy the portlet using ant deploy command from eclipse ant view

STEP: 7 to access your json web services enter the following url –
Note: if you access above url you will get blank page in browser but don’t worry. Make sure no exception will be occurred in console. Go through following url
Following is full URL to get json data according to my example


Note: Change port number according to your environment and change portlet-context name according to your portlet context name


  1. The message in Liferay 6.1.1 is {"exception":"No JSON web service action associated with path /student/get-stutend and method GET for //LiferayCustomJsonWebService-portlet"}

  2. {"exception":"Please sign in to invoke this method"}
    How to resolve this issue ?

  3. use this url



    follow reference links

  4. This was one of the greatest thing I have read. Thank you for sharing . Hope you continue writing educational post for every students.

  5. thank you... i will have such kind of plans.. thanks for your suggestion and keep in touch with for latest updates..also go through following link for liferay 6.1x json web services..

  6. The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Project Centers in Chennai for CSE.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

  7. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. Zerteck Digital Marketing agency in Karachi

  8. Fabulous post, you have denoted out some fantastic points, I likewise think this s a very wonderful website. I will visit again for more quality contents and also, recommend this site to all. Thanks. custom home design Horseshoe Bay tx


Recent Posts

Recent Posts Widget

Popular Posts