PUBLIC - Liferay Portal Community Edition
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-22831

EditExpandoAction.java throws NULL exception when a custom date attribute is added to Create Account page

    Details

    • Liferay Contributor's Agreement:
      Accept
    • Similar Issues:
      Show 5 results 

      Description

      Steps to reproduce:

      1. Add a custom attribute of type date to the User
      2. Create a hook for Create Account page - html/portlet/login/create_account.jsp
      3. Add the custom attribute created in step 1:
      4. Deploy the hook and open the create account page.
      5. Fill in the details and click Save.
      6. Observe that an error message is shown on the page "Sign In is temporarily unavailable."

      Logs:
      03:59:33,700 ERROR [jsp:154] java.lang.NullPointerException
      at com.liferay.portlet.expando.action.EditExpandoAction.getValue(EditExpandoAction.java:97)
      at com.liferay.portal.util.PortalImpl.getExpandoBridgeAttributes(PortalImpl.java:1354)
      at com.liferay.portal.util.PortalUtil.getExpandoBridgeAttributes(PortalUtil.java:385)
      at com.liferay.portal.service.ServiceContextFactory.getInstance(ServiceContextFactory.java:217)
      at com.liferay.portlet.login.action.CreateAccountAction.addUser(CreateAccountAction.java:216)
      at com.liferay.portlet.login.action.CreateAccountAction.processAction(CreateAccountAction.java:98)
      at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:169)
      at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:186)
      at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
      at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
      at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:652)

      I went through the code and saw that the problem is the code in EditExpandoAction.java where it is trying to create a date object from the input parameters:

      value = PortalUtil.getDate(
      valueDateMonth, valueDateDay, valueDateYear, valueDateHour,
      valueDateMinute, user.getTimeZone(), new ValueDataException());

      But since the user hasn't yet logged in, the user object is null and hence the call user.getTimeZone() throws NullPointerException.

      Regards,
      Kapil

        Activity

        Hide
        Kapil added a comment -

        Change the code in EditExpandoAction. Add check for null user object while creating date object from the input parameters:

        Current:
        value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, user.getTimeZone(), new ValueDataException());

        Fixed:
        if(user != null)

        { value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, user.getTimeZone(), new ValueDataException()); }

        else

        { value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, new ValueDataException()); }
        Show
        Kapil added a comment - Change the code in EditExpandoAction. Add check for null user object while creating date object from the input parameters: Current: value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, user.getTimeZone(), new ValueDataException()); Fixed: if(user != null) { value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, user.getTimeZone(), new ValueDataException()); } else { value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, new ValueDataException()); }
        Hide
        Paul Piao (Inactive) added a comment -

        Hi Kapil
        Can you send me the hook for Create Account page.
        I can't reproduce this ticket. I want to know you how to Add a custom attribute of type date to the User.
        do you add a date field in liferay custom Fields. And call it in create_account.jsp? or add date parameter by yourself.

        Thanks.

        Show
        Paul Piao (Inactive) added a comment - Hi Kapil Can you send me the hook for Create Account page. I can't reproduce this ticket. I want to know you how to Add a custom attribute of type date to the User. do you add a date field in liferay custom Fields. And call it in create_account.jsp? or add date parameter by yourself. Thanks.
        Hide
        Kapil added a comment -

        Hi Paul,

        As said in the 1st step to reproduce the issue, I added the attribute via control panel for the User entity. Attaching the screenshot of the same. The attribute that has the issue is the "Date of Shifting". I have also attached the jsp page.

        Regards,
        Kapil

        Show
        Kapil added a comment - Hi Paul, As said in the 1st step to reproduce the issue, I added the attribute via control panel for the User entity. Attaching the screenshot of the same. The attribute that has the issue is the "Date of Shifting". I have also attached the jsp page. Regards, Kapil
        Hide
        Paul Piao (Inactive) added a comment -

        Hi Kapil,
        Thank you for your report. I was able to reproduce this issue in 6.0.6 GA. I have also tested on issue on 6.1.x and trunk revision 96071 and I was unable to reproduce. This issue should be fixed in the next version of Liferay Portal.

        Thanks.

        Show
        Paul Piao (Inactive) added a comment - Hi Kapil, Thank you for your report. I was able to reproduce this issue in 6.0.6 GA. I have also tested on issue on 6.1.x and trunk revision 96071 and I was unable to reproduce. This issue should be fixed in the next version of Liferay Portal. Thanks.

          People

          • Assignee:
            Paul Piao (Inactive)
            Reporter:
            Kapil
            Recent user:
            Esther Sanz
            Participants of an Issue:
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 22 weeks, 5 days ago

              Development

                Structure Helper Panel