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

Multi-line META-INF/services/javax.servlet.ServletContainerInitializer aren't being read completely

    Details

      Description

      There is a bug in the initServletContainerInitializers method of com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor in Liferay Portal 7. The bug occurs whenever there is a META-INF/services/javax.servlet.ServletContainerInitializer file with more than one class name in one of the JARs in the WEB-INF/lib directory of a WAR that is deployed to Liferay Portal 7. In addition, the bug also occurs if there is a META-INF/services/javax.servlet.ServletContainerInitializer file with a comment in one of the JARs in the WEB-INF/lib directory of a WAR that is deployed to Liferay Portal 7.

      The specification of the META-INF/services/javax.servlet.ServletContainerInitializer file is described at http://docs.oracle.com/javase/8/docs/api/index.html?java/util/ServiceLoader.html, and this specification allows multiple ServletContainerInitializer classes to be listed in the META-INF/services/javax.servlet.ServletContainerInitializer file. In addition, comments beginning with the # character are also allowed in this file according to this specification. However, the initServletContainerInitializers method in WabBundleProcessor fails to correctly process META-INF/services/javax.servlet.ServletContainerInitializer files that contain comments or multiple ServletContainerInitializer class names, both of which are permitted by the specification for META-INF/services/javax.servlet.ServletContainerInitializer files.

      Steps to reproduce:

      1. Deploy attached portlet (com.lps72753.sample-1.0-SNAPSHOT.war)
      2. Access http://localhost:8080/o/com.lps72753.sample-1.0-SNAPSHOT/foo

       Expected behavior, youcan see these 3 messages:

      context attribute was set properly from Initializer!
      context attribute was set properly from Initializer2!
      context attribute was set properly from Initializer3WithComment!

       Actual behavior: previous three messages aren't showing, or just some of them.

       

        Attachments

          Activity

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 20 weeks, 4 days ago

                Packages

                Version Package
                7.0.0 DXP FP19
                7.0.3 CE GA4
                7.0.0 DXP SP4
                7.0.X EE
                7.1.X
                Master