Search code examples
intershop

Issues with custom URLRewrite rules in 7.9


Currently I'm having some issues with custom URL rewrite rules within ISH 7.9.

For some of our environments it works fine (like local and test), but on ACC and PROD it only seems to work from time to time after multiple deploys/restarts of the system.

We have created a custom cartridge that has a deploy.gradle file to exclude the files urlrewriterules.xml, domainsplittings.xml and syndication-targets.properties from the original cartridges. They get replaced by our custom files in the share/system/config/cluster folder. The static rules applied in the urlrewriterules.xml always work fine. However the rules that are coming from custom Java classes sometimes don't get well loaded by the RewriteRuleFactoryImpl returning back the below error:

[2018-11-07 08:20:37.906 +0100] WARN localhost ES1 appserver0 [ShipSupport-ebusiness-Site] [-] com.intershop.component.urlrewrite.internal.factory.RewriteRuleFactoryImpl [] [Storefront] [wJ5DCcg2CM5DCZPUUqdNu2D2fj8NZHaXjvP9qIZb] [yFAAAFvikjkOsqjA-0-00] "yFAAAFvikjkOsqjA-0-00" An implementation of rewrite rule type 'CustomCategory' does not exist.

The part of code in the urlrewriterules.xml that will call this java class is the following:

<!-- Custom Category Rule /c/<NAME_OF_LOWEST_CATEGORY> -->
<rule type="CustomCategory" priority="1000" name="custom category rule">
    <configurations>
       <configuration id="pathPrefix">/catalog</configuration>
        <configuration id="partsCatalogID">4393</configuration>
   </configurations>
</rule>

We also have the classes well created in our own cartridge such as CustomCategoryRewriteRule that extends BaseRewriteRule. URL Rewrite is enabled for those channels and we always Invalidate the cache in the channels that have it enabled.

The extension for the CustomCategory (defined in the same cartridge) is defined as below:

<?xml version="1.0" encoding="UTF-8"?>
<extensionpoint:ExtensionPointModel xmlns:extensionpoint="http://www.intershop.de/extensionpoint/2011" name="CustomCategoryRewriteRule"> 
  <extensionBindings type="java" extensionPoint="com.intershop.component.urlrewrite.capi.RewriteRule-RewriteRule.create" extension="com.package.CustomCategoryRewriteRule" priority="1"/>
</extensionpoint:ExtensionPointModel>

Also the app-extension.component is defined in the same cartridge as below:

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://www.intershop.de/component/2010" scope="global">
    <fulfill requirement="selectedCartridge" value="cartridge_name" of="intershop.SLDSystem.Cartridges"/>
    <fulfill requirement="selectedCartridge" value="cartridge_name" of="intershop.EnterpriseBackoffice.Cartridges"/>
</components>

We followed this article to confirm on how to do it: https://support.intershop.com/kb/index.php/Display/B28069 We also have it working fine in another project, but using Intershop 7.8.

Do you have any idea on what might be the cause?

Thank you!


Solution

  • Besides the implementation, you also need to create an extension file in <cartridge>/staticfiles/cartridge/extensions. This is the actual registration of the rewrite rule for the lookup mechanism. See the following example:

    <?xml version="1.0" encoding="UTF-8"?>
    <extensionpoint:ExtensionPointModel xmlns:extensionpoint="http://www.intershop.de/extensionpoint/2011" name="CustomRewriteRule.extension">
        <extensionBindings type="java" extensionPoint="com.intershop.component.urlrewrite.capi.RewriteRule-RewriteRule.create" extension="com.package.CustomCategoryRewriteRule " priority="1"/>
    </extensionpoint:ExtensionPointModel>
    

    Also the cartridge that contains these extensions needs to be registered at the application types via a component file in <cartridge>/staticfiles/cartridge/components. This is needed so that the extension is loaded correctly in the correct application context. See this example:

    <?xml version="1.0" encoding="UTF-8" ?>
    <components xmlns="http://www.intershop.de/component/2010">
        <fulfill requirement="selectedCartridge" value="your_custom_cartridge" of="intershop.SLDSystem.Cartridges" /> 
        <fulfill requirement="selectedCartridge" value="your_custom_cartridge" of="intershop.B2CBackoffice.Cartridges" />
        <fulfill requirement="selectedCartridge" value="your_custom_cartridge" of="intershop.B2CResponsive.Cartridges" />
    </components>
    

    I'm not quite sure if you need to register it for all of these applications, but these are the ones we used in our last project. If you use different application types or have custom ones, make sure to add those accordingly.