【问题标题】:NullPtr exception while getting country names and country codes in backoffice在后台获取国家名称和国家代码时出现 NullPtr 异常
【发布时间】:2020-05-27 13:33:31
【问题描述】:

升级到 Intershop CM 7.10.18.1 后,我们在后台打开商店详细信息页面时出现 NullPtr 异常。 商店详情的 ISML 模板是 EditStore_52.isml,其中包含 ISCountrySelectBox 模块,该模块进一步调用 getCountryNamesAndCodes() 方法。 由于返回 null 的带下划线的调用,该方法因 NullPtr 异常而失败。

我们想知道这是否是一个错误以及预期的代码是否应该是:

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

请就这种情况的解决方法提出建议。 以下是异常的堆栈跟踪。

【问题讨论】:

    标签: intershop


    【解决方案1】:

    Intershop 提供可以通过Operations 后台导入/导出的地址数据(例如,使用组织Operationshttps://localhost:8443/INTERSHOP/web/WFS/SLDSystem 登录)。开箱即用的地址数据如下所示:

    <country>
       <id>DE</id>
       <custom-attributes>
                <custom-attribute dt:dt="string" name="displayName" xml:lang="de-DE">Deutschland</custom-attribute>
                <custom-attribute dt:dt="string" name="displayName" xml:lang="fr-FR">Allemagne</custom-attribute>
                <custom-attribute dt:dt="string" name="displayName" xml:lang="en-US">Germany</custom-attribute>
            </custom-attributes>
    </country>
    

    如您所见,它仅包含 de-DE、fr-FR 和 en-US 的 displayName 属性值。在您的情况下,一种可能的解决方法是导出数据,包括缺少的属性值并再次导入。

    请注意:为此提供修复的工作已经在进行中。给您带来的不便,我深表歉意。

    【讨论】:

    • 感谢您的两个回答,我们设法通过使用 ISML 模板解决方法,我们将等待未来的修复
    • 不错。不过,您会在客户/用户的地址详细信息页面上遇到与 ICM 管理应用程序相同的问题。
    【解决方案2】:

    更方便的方法(因为编辑 xml 导入文件很乏味)是使用 guice 模块覆盖来替换错误的实现。简而言之:

    • com.intershop.component.region.internal.geoobject.LocalizedCountryNamesProviderImpl 类的原始实现复制粘贴到自定义盒中您自己的类中。例如:我刚刚在墨盒app_sf_responsive 中创建了一个类AppSFLocalizedCountryNamesProviderImpl 来测试它。
    • 根据您的需要调整上述方法
    • 创建覆盖模块(请参阅Cookbook - Dependency Injection and ObjectGraphs)。按照我的示例,模块 configure 操作应如下所示:
        @Override
        protected void configure()
        {
            bind(LocalizedCountryNamesProvider.class).to(AppSFLocalizedCountryNamesProviderImpl.class);
            bindProvider(com.intershop.component.foundation.capi.localization.LocalizedCountryNamesProvider.class)
            .to(AppSFLocalizedCountryNamesProviderImpl.class);
        }
    
    • 发布您的磁带,重新启动您的服务器

    【讨论】:

    • 不用说他的解决方案符合 HACK 标准。如果您这样做后又忘记了,您将无法从我们提供的修复中获益。
    猜你喜欢
    • 2016-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多