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

          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:
              2 years, 21 weeks, 4 days ago

                Packages

                Version Package
                7.1.X
                Master