Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 6.1.1 CE GA2, 6.1.20 EE GA2
-
Fix Version/s: 6.1.X EE, 6.2.0 CE M2
-
Component/s: Tools, Tools > Plugins SDK > Portlets
-
Labels:
-
Environment:Any, tested with Liferay JBoss & Tomcat bundles
-
Branch Version/s:6.1.x
-
Backported to Branch:Committed
-
Epic/Theme:
-
Fix Priority:5
-
Similar Issues:
Description
We have the structure where applicationContext.xml contains shared beans (service layer, dao layer and such) and is loaded by org.springframework.web.context.ContextLoaderListener . Additionally all portlets have their own context loading MVC related beans (controllers, view resolvers, etc).
Generated listeners in web.xml on version 6.1 GA1:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener</listener-class>
</listener>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
</listener>
After upgrading to Liferay 6.1 GA2 deployment sorts listeners in web.xml alphabetically:
<listener>
<listener-class>com.liferay.portal.kernel.servlet.PluginContextListener</listener-class>
</listener>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
This causes portlet context to be loaded first and dependent beans from application context are missing.

Problem is with implementation in the com/liferay/portal/tools/deploy/BaseDeployer.java. In web.xml it is adding plugin context listener before any custom listener. Here is custom listener org.springframework.web.context.ContextLoaderListener so in current implementation it is loaded last. And it should be first to provide loading main application context beans.
I made change to put plugin context listener after customer listeners, and also to strip out comments from web.xml because they can potential problems in searching inside web.xml.
You can check fix on https://github.com/vpugar/liferay-portal/blob/6.1.x_LPS-29103/portal-impl/src/com/liferay/portal/tools/deploy/BaseDeployer.java