23 November, 2016

Spring MVC Portlet Migration - DXP

Friends,

Do you want to migrate your Spring MVC portlet into DXP ? yooo here are the steps you will have to follow to get it migrate.

Before we jump into steps, let me light up regarding spring mvc. Actually Spring MVC is purely used for web project architect and there is no any specific intention to get it convert into OSGi module jar. So here we may not be able to convert it into module jar but  such kind of portlets will get deployed as a war file only and Liferay container will convert into OSGi compatible WAB (Web Application Bundle) project by  Liferay WAB Generator.

Follow below steps to get it convert


  • Create a liferay plugin portlet using create new Liferay plugin project wizard and choose portlet framework ‘Spring MVC’. Make sure you give the same name of your existing portlet which you are going to convert from 6.X.



  • If you see the structure of newly created portlet, it would be very much similar to previous portlet project but each liferay related xml descriptors (like portlet.xml,liferay-portlet.xml etc.) will have different xml DTD definition.

  • Copy 6.X portlet folders manually into newly created spring mvc portlet
    • First copy all folders from docroot except WEB-INF and META-INF and put it into newly created DXP portlet.
    •  Next step, manually copy all content inside the Liferay descriptor xml files. You can simply copy & paste lib,src and tld folders directly. Don’t copy META-INF folder.   
Note : Here most important point is, inside lib directory all your external dependency jars should be there including spring related jars.If you define portal-dependency-jars property liferay-plugin-package.properties for the libraries which are available in Tomcat/ROOT/WEB-INF/lib folder then it will help you to compile the project but when you deploy the portlet it will give you error. So it seems some liferay issue to load spring context.

  • So just copy spring-aop.jar,spring-beans.jar,spring-context.jar,spring-core.jar,spring-expression.jar,spring-web.jar,spring-webmvc.jar,spring-webmvc-portlet.jar    JARs from tomcat/ROOT/WEB-INF/lib folder and put it inside portlet WEB-INF/lib folder
  • Make sure that you configure application context xml path proper in web.xml as well as portlet.xml
  • Once you copy code from 6.1 to DXP project, just run Breaking API changes tool and make all the necessary changes there for liferay related API changes and make it work.
  •  
  • Now just deploy your portlet using Ant or maven based on the portlet plugin project which you have create
How to test converted portlet is working or not
  • Deploy the war file in hot deploy folder
  • It will start deploying in tomcat server so just check tomcat log.If it shows portlet available for use then it's successfully deployed into tomcat and available to use 
  • It also should be in active state in gogo shell. If it’s not then you can run  command  g! start 589 to check what stopping bundle to be active
  • Now go to Liferay and add converted portlet into page
Here you go !!!! You are done my friend....

Popular Posts

Featured Post

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...