簡體   English   中英

在后台獲取國家名稱和國家代碼時出現 NullPtr 異常

[英]NullPtr exception while getting country names and country codes in backoffice

升級到 Intershop CM 7.10.18.1 后,我們在后台打開商店詳細信息頁面時出現 NullPtr 異常。 商店詳情的ISML 模板是EditStore_52.isml,其中包括ISCountrySelectBox 模塊,該模塊還調用getCountryNamesAndCodes() 方法。 由於返回 null 的帶下划線的調用,該方法因 NullPtr 異常而失敗。 失敗的方法

我們想知道這是否是一個錯誤以及預期的代碼是否應該是:

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

請就這種情況的解決方法提出建議。 以下是異常的堆棧跟蹤。

異常堆棧跟蹤

Intershop 提供可以通過Operations后台導入/導出的地址數據(例如,使用組織Operations登錄https://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屬性值。 在您的情況下,一種可能的解決方法是導出數據,包括缺少的屬性值並再次導入。

請注意:為此提供修復的工作已經在進行中。 對不起給您帶來不便。

更方便的方法(因為編輯 xml 導入文件很乏味)是使用 guice 模塊覆蓋替換錯誤的實現。 簡而言之:

  • 將 class com.intershop.component.region.internal.geoobject.LocalizedCountryNamesProviderImpl的原始實現復制粘貼到您自己的 class 中。 例如:我剛剛在墨盒app_sf_responsive AppSFLocalizedCountryNamesProviderImpl測試這個。
  • 根據您的需要調整上述方法
  • 創建一個覆蓋模塊(請參閱Cookbook - 依賴注入和 ObjectGraphs )。 按照我的示例,模塊configure操作應如下所示:
    @Override
    protected void configure()
    {
        bind(LocalizedCountryNamesProvider.class).to(AppSFLocalizedCountryNamesProviderImpl.class);
        bindProvider(com.intershop.component.foundation.capi.localization.LocalizedCountryNamesProvider.class)
        .to(AppSFLocalizedCountryNamesProviderImpl.class);
    }
  • 發布您的墨盒,重新啟動您的服務器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM