Migrating to PortletMVC4Spring and Jakarta
There are two possible migrations:
-
You’ve already used PortletMVC4Spring, and you want to migrate your application to Jakarta.
-
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.actionmust becomejakarta.portlet.action) web.xml, specifically schema declarationsLanguage.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:
-
In your
build.gradledescriptor, use the Spring Framework version 6 artifacts by replacing dependencies on thespring-webmvc-portletartifact with thecom.liferay.portletmvc4spring.frameworkartifact.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' -
In your
WEB-INF/portlet.xmldescriptor, replace uses oforg.springframework.web.portlet.DispatcherPortletwithcom.liferay.portletmvc4spring.DispatcherPortlet. -
Replace uses of the Spring Portlet MVC
AnnotationMethodHandlerAdapterclass with the PortletMVC4SpringPortletRequestMappingHandlerAdapterclass.PortletRequestMappingHandlerAdapteruses theHandlerMethodinfrastructure that Spring Web MVC 5.1.x is based on. -
If you specified
AnnotationMethodHandlerAdapteras a<bean>in a Spring configuration descriptor, replace its fully-qualified class nameorg.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapterwithcom.liferay.portletmvc4spring.mvc.method.annotation.PortletRequestMappingHandlerAdapter.Also address these bean property changes:
-
customModelAndViewResolver(no longer available) -
customArgumentResolver(no longer available) -
customArgumentResolvers(specify a list ofHandlerMethodArgumentResolverinstead of a list ofWebArgumentResolver)
-
-
If you’re using Apache Commons Fileupload, update your Spring configuration descriptor:
-
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" />NoteAlternatively, you can use the native Portlet 3.0 file upload support that PortletMVC4Spring provides by setting the
portletMultipartResolver<bean>element’sclasstocom.liferay.portletmvc4spring.multipart.StandardPortletMultipartResolver -
Remove these dependencies from your
pom.xmlorbuild.gradledescriptor:<dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </dependency>
-
-
Throughout your project, replace all uses of the
org.springframework.web.portletpackage path withcom.liferay.portletmvc4spring.
Congratulations! You migrated your project from Spring Portlet MVC to PortletMVC4Spring.