Search code examples
intershop

NullPtr exception while getting country names and country codes in backoffice


After upgrading to Intershop CM 7.10.18.1, we are getting NullPtr exceptions while opening store detail page in backoffice. ISML template for store details is EditStore_52.isml, which includes ISCountrySelectBox module, which futhermore calls getCountryNamesAndCodes() method. That method fails with NullPtr exception because of underlined call which returns null. failing method

We are wondering whether this is a bug and whether the intended code was supposed to be:

countriesMap.put(country.getId(), country.getDisplayName(currentLocale));

Please advise on workaround for this situation. The following is a stack trace for exception.

exception stack trace


Solution

  • The more convenient way (because editing xml import files is tedious) would be to replace the erroneous implementation using guice module override. In a nutshell:

    • Copy paste the original implementation of class com.intershop.component.region.internal.geoobject.LocalizedCountryNamesProviderImpl into a class of your own in your custom cartridge. For example: I just created a class AppSFLocalizedCountryNamesProviderImpl in cartridge app_sf_responsive to test this.
    • Adapt above method according to your needs
    • Create an override module (See Cookbook - Dependency Injection and ObjectGraphs). Following my example the modules configure operation should look like this:
        @Override
        protected void configure()
        {
            bind(LocalizedCountryNamesProvider.class).to(AppSFLocalizedCountryNamesProviderImpl.class);
            bindProvider(com.intershop.component.foundation.capi.localization.LocalizedCountryNamesProvider.class)
            .to(AppSFLocalizedCountryNamesProviderImpl.class);
        }
    
    • Publish your cartridge, Restart your server