Using Spring

Migrating to PortletMVC4Spring and Jakarta

There are two possible migrations:

  1. You’ve already used PortletMVC4Spring, and you want to migrate your application to Jakarta.

  2. You want to migrate a Spring Portlet MVC portlet to use Spring Framework 5.0+, which requires PortletMVC4Spring.

Both migrations are easy, but the first one is easier.

Migrating PortletMVC4Spring from Java EE to Jakarta

Liferay 2025.Q3+ uses Jakarta instead of Java EE. When you upgrade to a Jakarta-based Liferay, you must update all javax.portlet references to jakarta.portlet. That’s it! Be careful, however, as these can hide in various places:

  • Import statements
  • Portlet action naming conventions (e.g., javax.portlet.action must become jakarta.portlet.action)
  • web.xml, specifically schema declarations
  • Language.properties, specifically portlet properties

When you update all of these references, your PortletMVC4Spring application works as-is, with no changes.

Migrating from Spring Portlet MVC to PortletMVC4Spring

To continue developing a portlet to use Spring Framework version 5.0 onward, migrate it from Spring Portlet MVC to PortletMVC4Spring. Here are the steps:

  1. In your build.gradle descriptor, use the Spring Framework version 6 artifacts by replacing dependencies on the spring-webmvc-portlet artifact with the com.liferay.portletmvc4spring.framework artifact.

      compile group: 'com.liferay.portletmvc4spring', name: 'com.liferay.portletmvc4spring.framework', version: '5.3.2'
      compile group: 'com.liferay.portletmvc4spring', name: 'com.liferay.portletmvc4spring.security', version: '5.3.2'
    
  2. In your WEB-INF/portlet.xml descriptor, replace uses of org.springframework.web.portlet.DispatcherPortlet with com.liferay.portletmvc4spring.DispatcherPortlet.

  3. Replace uses of the Spring Portlet MVC AnnotationMethodHandlerAdapter class with the PortletMVC4Spring PortletRequestMappingHandlerAdapter class. PortletRequestMappingHandlerAdapter uses the HandlerMethod infrastructure that Spring Web MVC 5.1.x is based on.

  4. If you specified AnnotationMethodHandlerAdapter as a <bean> in a Spring configuration descriptor, replace its fully-qualified class name org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter with com.liferay.portletmvc4spring.mvc.method.annotation.PortletRequestMappingHandlerAdapter.

    Also address these bean property changes:

  5. If you’re using Apache Commons Fileupload, update your Spring configuration descriptor:

    1. Replace this legacy bean:

      <bean id="portletMultipartResolver"
      	class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver" />
      

      With this new one from PortletMVC4Spring:

      <bean id="portletMultipartResolver"
      	class="com.liferay.portletmvc4spring.multipart.CommonsPortletMultipartResolver" />
      
      Note

      Alternatively, you can use the native Portlet 3.0 file upload support that PortletMVC4Spring provides by setting the portletMultipartResolver <bean> element’s class to com.liferay.portletmvc4spring.multipart.StandardPortletMultipartResolver

    2. Remove these dependencies from your pom.xml or build.gradle descriptor:

       <dependency>
       	<groupId>commons-fileupload</groupId>
       	<artifactId>commons-fileupload</artifactId>
       </dependency>
       <dependency>
       	<groupId>commons-io</groupId>
       	<artifactId>commons-io</artifactId>
       </dependency>
      
  6. Throughout your project, replace all uses of the org.springframework.web.portlet package path with com.liferay.portletmvc4spring.

  7. Continue developing your portlet using PortletMVC4Spring.

  8. Build and deploy your project.

Congratulations! You migrated your project from Spring Portlet MVC to PortletMVC4Spring.

PortletMVC4Spring

Developing a Portlet Using PortletMVC4Spring

Configuring Dependencies