A navigation menu can't be removed

Issue

  • A navigation menu cannot be deleted by the user. On a clean instance, the issue can be reproduced with the provided user's database. 

  • Steps To Reproduce:
    (i) Restore the attached DB to a Liferay 7.2 fix pack dxp-7 portal with MySQL 5.7
    (ii) Navigate to the Child Sites from the created site and locate the United States site (as mentioned by the user).
    (iii) Navigate to Site builder > Navigation menus
    (iv) Locate the "OLD__footer-about-us" menu
    (v) Click on the three dots on the right and click Delete
    Expected Results: The navigation menu is deleted.
    Actual Results: The menu is not deleted and the following exceptions appear on the logs. 
  • 2021-04-29 16:04:52.859 ERROR [http-nio-8080-exec-7][PortletServlet:119] javax.portlet.PortletException: java.lang.reflect.UndeclaredThrowableException javax.portlet.PortletException: java.lang.reflect.UndeclaredThrowableException at com.liferay.portal.kernel.portlet.bridges.mvc.BaseMVCActionCommand.processAction(BaseMVCActionCommand.java:69) at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:378) at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:88) at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:260) at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:77) at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:50) at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:115) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153) at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:62) at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120) at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48) at com.liferay.portlet.internal.InvokerPortletImpl.invoke(InvokerPortletImpl.java:589) at com.liferay.portlet.internal.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:632) at com.liferay.portlet.internal.InvokerPortletImpl.processAction(InvokerPortletImpl.java:304) at ..........................................................................................................................................................................................................com.liferay.portal.kernel.portlet.bridges.mvc.BaseMVCActionCommand.processAction(BaseMVCActionCommand.java:61) ... 161 more Caused by: com.liferay.portal.kernel.exception.NoSuchGroupException: No Group exists with the primary key 1425519 at com.liferay.portal.service.persistence.impl.GroupPersistenceImpl.findByPrimaryKey(GroupPersistenceImpl.java:13329) at com.liferay.portal.service.persistence.impl.GroupPersistenceImpl.findByPrimaryKey(GroupPersistenceImpl.java:13345) at com.liferay.portal.service.impl.GroupLocalServiceImpl.getGroup(GroupLocalServiceImpl.java:1606) at sun.reflect.GeneratedMethodAccessor217.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at .........................................................................................

Environment

  • Liferay DXP 7.2 fix pack 7

Resolution

  • This observed behavior isn't a bug, rather, the navigation menu is looking for a GroupID that doesn't exist.

  • The navigation menu will no longer appear after running the following groovy script, however, the user may need to clear the database cache for the change to take effect.

  • Navigate to the Control Panel → Server Administration → Script. Change the script type to Groovy and replace the code in the scripting console with the following:

  • import com.liferay.portal.kernel.dao.jdbc.DataAccess;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    
    try {
        Connection connection = DataAccess.getConnection();
    
        PreparedStatement prepareStatement =
           connection.prepareStatement(
                "delete from sitenavigationmenuitem " + 
                "where groupId  not in (select groupId from group_)");
    
        prepareStatement.executeUpdate();
    
        connection.commit();
    }
    catch (Throwable t) {
        out.println(t);
    

Additional Information

  • Please make ensure that a database backup is created beforehand and continue to maintain adequate backups in case a rollback is required.
  • We highly recommend testing the above-suggested approach in a lower environment and then moving it to production as per your discretion if you feel comfortable with it.
  • We have a channel called "Global Service Team" that works primarily in development and implementation.
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0