Search code examples
sap-commerce-cloudb2b

"[PageNotFound] No mapping for GET" error after SAP Hybris upgrade


We are required to update our Hybris version from 2011 to 2211. A developer from SAP has already provided the necessary changes to multicountry extension and others so that our storefront will be ready for the upgrade. After the said upgrade, our home page is not working anymore in our local. We get the error "[PageNotFound] No mapping for GET" when trying to access our home page. The status code is 404. We have the same data, local.properties, localextensions.xml. The weird thing is that only home page has the issue. Other pages like product page is working if we change the url directly to bypass home page. Our smartedit is also not working. We get the issue "This page doesn't exist".

We've already tried reimporting our impex that is used to insert our CMS components but it is still not working.


Solution

  • In order to avoid receiving a 404 on the landing page, you need to change the class in the /yacceleratorstorefront/web/src/de/hybris/platform/yacceleratorstorefront/web/mvc/AcceleratorUrlPathHelper.java file to the following:

    Please add the missing methods in your class.

    Sample Code:

    package de.hybris.platform.yacceleratorstorefront.web.mvc;
     
    import de.hybris.platform.acceleratorstorefrontcommons.constants.WebConstants;
     
    import javax.servlet.http.HttpServletRequest;
     
    import org.apache.commons.lang.StringUtils;
    import org.springframework.web.util.UrlPathHelper;
     
    /**
     * This implementation overrides the default implementation of Spring framework's {@link UrlPathHelper}
     * so that context path and servlet mapping tricks Spring MVC as if UrlEncoding is not present.
     */
    public class AcceleratorUrlPathHelper extends UrlPathHelper
    {
        private boolean alwaysUseFullPath;
     
        @Override
        public String getContextPath(final HttpServletRequest request)
        {
            final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
            final String contextPath = super.getContextPath(request);
     
            final String toRemove = urlEncodingAttributes != null ? urlEncodingAttributes.toString() : "";
            return StringUtils.remove(contextPath, toRemove);
        }
     
        @Override
        public String getPathWithinServletMapping(final HttpServletRequest request)
        {
            final String servletPath = super.getServletPath(request);
            if ("".equals(servletPath))
            {
                return "/";
            }
            return super.getPathWithinServletMapping(request);
        }
     
        @Override
        public String getLookupPathForRequest(HttpServletRequest request)
        {
            final String pathWithinApplication = getPathWithinApplication(request);
     
            // Always use full path within current servlet context?
            if (this.alwaysUseFullPath)
            {
                return pathWithinApplication;
            }
     
            // Else, use path within current servlet mapping if applicable
            final String rest = getPathWithinServletMapping(request);
            if (org.springframework.util.StringUtils.hasLength(rest))
            {
                return rest;
            }
            return pathWithinApplication;
        }
     
        @Override
        public void setAlwaysUseFullPath(final boolean alwaysUseFullPath)
        {
            super.setAlwaysUseFullPath(alwaysUseFullPath);
            this.alwaysUseFullPath = alwaysUseFullPath;
        }
    }