Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-76229

ClassNotFoundException is thrown for a listener-class when deploying a WAR in Liferay DXP

Details

    Description

      Description
      When deploying a war-styled plugin with listener-classes declared in web.xml, the deployed plugin does not work as expected.

      Details
      WAR-styled plugins are processed by Liferay's WAB Generator during deployment.
      Based on the documentation, the listener-classes declared should have their packages added under the Import-Package header in the WAB's META-INF/MANIFEST.MF file.

      The WAB Generator detects packages a plugin's JSPs and descriptor files reference. 
      The descriptor files include web.xml, liferay-web.xml, portlet.xml, liferay-portlet.xml, and liferay-hook.xml. 
      
      The WAB Generator verifies whether the detected packages are in the plugin's WEB-INF/classes folder or in a JAR file in the plugin's WEB-INF/lib folder. 
      Packages that aren't found in either location are added to an Import-Package header in the WAB's META-INF/MANIFEST.MF file.
      

      Reference: https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/using-the-wab-generator

      Since the packages of the declared listener-classes are not added to the Import-Package header, a ClassNotFoundException is being thrown.

      Steps to Reproduce

      1. Startup Liferay
      2. Deploy the attached wab-import-poc.war
      3. Observe log
        • Expected Result: The bundle will boot successfully
        • Actual Result: ClassNotFoundException is thrown
      4. Shutdown Liferay
      5. Include the following portal property:
        module.framework.web.generator.headers.Import-Package[wab-import-poc]=com.liferay.portal.kernel.spring.context
        
      1. Restart Liferay and wait till it starts up completely
      2. Re-deploy the attached wab-import-poc.jar
        • Notice: ClassNotFoundException is no longer thrown.

      Additional Details
      Attached is a POC war-styled plugin that was generated using Liferay Blade's: WAR MVC Portlet template.
      Reference: https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/war-mvc-portlet-template

      The only change was modifying web.xml to include the following listener-class tag:

      <listener>
      	<listener-class>com.liferay.portal.kernel.spring.context.PortletContextLoaderListener</listener-class>
      </listener>
      

      Attached is also the source: wab-import-poc-src.zip

      Attachments

        Activity

          People

            linda.sui Linda Sui
            eric.yan Eric Yan
            Kiyoshi Lee Kiyoshi Lee
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              5 years, 24 weeks, 1 day ago

              Packages

                Version Package
                7.0.0 DXP FP35
                7.0.0 DXP SP7
                7.0.5 CE GA6
                7.0.X
                7.1.0 M1
                7.1.X
                Master