cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Null Pointer at sitethemeresolverutils

0 Kudos

When I am trying to hit any page other than login page in incognito mode in browser when my site is not logged in .

Instead of going from DeviceDetectionBeforeControllerHandler

going to StorefrontResourceBundleSource

Please help what I am missing .

Giving below error :

nested exception is java.lang.NullPointerException:

Cannot invoke "de.hybris.platform.commerceservices.enums.UiExperienceLevel.getCode()" because "uiExperienceLevel" is null] with root cause","contextMap":{"sourceClassName":"org.apache.catalina.core.StandardWrapperValve","sourceMethodName":"invoke"},"thrown":{"localizedMessage":"Cannot invoke "de.hybris.platform.commerceservices.enums.UiExperienceLevel.getCode()"

because "uiExperienceLevel" is null","message":"Cannot invoke "de.hybris.platform.commerceservices.enums.UiExperienceLevel.getCode()"

because "uiExperienceLevel" is null","name":

"java.lang.NullPointerException",

"extendedStackTrace":[{"class":"com.storefront.util.SiteThemeResolverUtils",

"method":"resolveThemeForCurrentSite","file":"SiteThemeResolverUtils.java","line":35},

{"class":"com.storefront.web.theme.StorefrontResourceBundleSource",

"method":"determineDefaultThemeName","file":"StorefrontResourceBundleSource.java","line":215},

{"class":"com.brgt.storeportal.storefront.web.theme.StorefrontResourceBundleSource",

"method":"getMessage","file":"StorefrontResourceBundleSource.java","line":190},

{"class":"org.springframework.context.support.AbstractApplicationContext","method":"getMessage",

"file":"AbstractApplicationContext.java","line":1311},

{"class":"org.springframework.context.support.MessageSourceAccessor","method":"getMessage",

"file":"MessageSourceAccessor.java","line":87},{"class":"org.springframework.security.access.vote.AffirmativeBased",

"method":"decide","file":"AffirmativeBased.java","line":73},

adiputera
Active Participant

you should format your question using code snippet first, so others can read it clearly

Accepted Solutions (0)

Answers (1)

Answers (1)

adiputera
Active Participant
0 Kudos

You can try set default value of uiExperienceLevel if it's null in SiteThemeResolverUtils.resolveThemeForCurrentSite()

public String resolveThemeForCurrentSite()
{
    UiExperienceLevel uiExperienceLevel = getUiExperienceService().getUiExperienceLevel();
    uiExperienceLevel = uiExperienceLevel != null ? uiExperienceLevel : UiExperienceLevel.DESKTOP;

    // Resolve Theme from CMSSiteService
    final CMSSiteModel currentSite = getCmsSiteService().getCurrentSite();
    if (currentSite != null && uiExperienceLevel != null)
    {
        return combineSiteAndTheme(uiExperienceLevel.getCode(), currentSite.getUid(), getThemeNameForSite(currentSite));
    }
    return null;
}