Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-73282 Implement Portlet 3.0
  3. LPS-91305

Portlet 3.0: Improve logging for @Dependent strings that are injected into @ApplicationScoped beans

    Details

      Description

      This task involves improving logging for @Dependent strings that are injected into @ApplicationScoped beans.

      The Portlet 3.0 Specification indicates that the following code will cause CDI to inject @Dependent strings:

      "MyBeanPortlet.java"
      public class MyBeanPortlet {
      
          @ContextPath @Inject private String contextPath;
      
          @Namespace @Inject private String namespace;
      
          @PortletName @Inject private String portletName;
      
          @WindowId @Inject private String windowId;
      }
      

      If the class is annotated with @ApplicationScoped then an error message must be logged in the console log.

      Steps to Verify

      • Deploy the attached WAR to $LIFERAY_HOME/deploy and add the portlet named "LPS-91305" to the portal page.

      Expected Results

      The portlet will render the following:

      LPS-91305 check the console log to make sure that error messages are present regarding
      injecting @Dependent strings into @Application scoped beans occurred when the portlet
      was deployed.
      

      And the console log will indicate the following error messages:

      java.lang.IllegalStateException: Unable to @Inject @ContextPath into field because it is a @Dependent
      String that can only be injected during a request. Annotate the parent class with
      @PortletRequestScoped instead of @ApplicationScoped.
      

        Attachments

        1. lps-91305-portlet-1.0.0.war
          4 kB
          Neil Griffin

          Activity

            People

            • Assignee:
              shuyang.zhou Shuyang Zhou
              Reporter:
              neil.griffin Neil Griffin
              Recent user:
              Enterprise Release HU
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                37 weeks ago

                Packages

                Version Package
                7.1.X
                Master