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

Add support for servletContext.setInitParameter() when servletContext didn't start yet

    Details

      Description

      Servlet 3 api allows to set init parameters (those with <context-param> if coming from web.xml) while servletContext isn't initialized yet.

      For example, If doing so from a servletContainerInitializer, it will throw an IllegalStateException.

      This will make many frameworks (like Spring Boot like here: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java#L229) to not work, as they use this API method.

      Steps to reproduce

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

      Expected behaviour: you should see 3 messages like this at the end of the page:

      setting context Init param works!
      
      context Init param is visible from Listener!
      
      context attribute was set properly from Initializer!
      

      Actual behaviour: those three messages doesn't show exactly like that, stating some of those doesn't work.

      First seen in forums: https://web.liferay.com/community/forums/-/message_boards/view_message/81031101

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 46 weeks ago

                Packages

                Version Package
                7.0.0 DXP FP10
                7.0.0 DXP SP2
                7.0.3 CE GA4
                7.1.X
                Master