SAP Hybris 无法创建自定义横幅组件
Posted
技术标签:
【中文标题】SAP Hybris 无法创建自定义横幅组件【英文标题】:SAP Hybris can't create custom banner component 【发布时间】:2020-09-12 00:01:00 【问题描述】:我想创建自定义横幅组件,扩展自 SimpleBannerComponent
。但是我创建后,在Backoffice中创建失败,见下文。
1) 我将此项目添加到我的*-items.xml
文件中。
<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent"
jaloclass="my.package.core.jalo.components.PromotionBannerCMSComponent">
<description>Promotion banner component</description>
<deployment table="PromotionBanners" typecode="15301"/>
<attributes>
<attribute qualifier="code" type="java.lang.String">
<persistence type="property"/>
<modifiers/>
<description>Banner name (not unique)</description>
</attribute>
<attribute qualifier="title" type="localized:java.lang.String">
<description>Title</description>
<modifiers read="true" write="true" search="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="position" type="SimpleBannerPositionEnum">
<description>Banner position</description>
<modifiers optional="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="altText" type="localized:java.lang.String">
<description>Banner alt text</description>
<modifiers optional="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="titleSecondary" type="localized:java.lang.String">
<description>Title secondary</description>
<persistence type="property" />
<modifiers />
</attribute>
<attribute qualifier="urlLoc" type="localized:java.lang.String">
<description>Banner url</description>
<persistence type="property" />
<modifiers />
</attribute>
</attributes>
</itemtype>
2) 我做了ant clean all
,重新启动了服务器,我运行HAC -> Update
并检查了我的自定义扩展名并检查了Update running system
。然后我又重新启动了服务器。
3) 我想在后台 WCMS->Components->Add
中创建组件,但它失败并出现错误 - 我已打开 flexible.search.exception.show.query.details
来查看它:
[ConfigurableFlowController] Object could not be saved
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException: Object could not be saved
和
Caused by: de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.servicelayer.interceptor.impl.UniqueAttributesInterceptor@716c1b71]: unexpected validator error: SQL search error - Unknown column 'item_t0.p_catalogversion' in 'where clause' query = 'SELECT item_t0.PK FROM cmscomponent item_t0 WHERE
.
.
现在我连基本的 SimpleBannerComponent 都无法创建,其他组件也无法创建。更新有问题吗? 我正在使用 Hybris 1811.18。
【问题讨论】:
你试过ant updatesystem
吗?
【参考方案1】:
我能看到的一个问题是应该删除部署表,因为最佳做法是仅在扩展 GenericItem 时提供一个(当您不指定父级时类型将自动设置)。所以你的定义应该是这样的:
<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent"
jaloclass="my.package.core.jalo.components.PromotionBannerCMSComponent">
<description>Promotion banner component</description>
<attributes>
<attribute qualifier="code" type="java.lang.String">
<persistence type="property"/>
<modifiers/>
<description>Banner name (not unique)</description>
</attribute>
<attribute qualifier="title" type="localized:java.lang.String">
<description>Title</description>
<modifiers read="true" write="true" search="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="position" type="SimpleBannerPositionEnum">
<description>Banner position</description>
<modifiers optional="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="altText" type="localized:java.lang.String">
<description>Banner alt text</description>
<modifiers optional="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="titleSecondary" type="localized:java.lang.String">
<description>Title secondary</description>
<persistence type="property" />
<modifiers />
</attribute>
<attribute qualifier="urlLoc" type="localized:java.lang.String">
<description>Banner url</description>
<persistence type="property" />
<modifiers />
</attribute>
</attributes>
尝试初始化系统以进行测试,以便从数据库中删除旧类型及其关联表。
【讨论】:
One of the problem that I am able to see is that the deployment table should be deleted
- 这不是问题的根本原因。只是在这种情况下,放置一个额外的部署表将需要 FS 查询来创建更多的连接。【参考方案2】:
我用 1905.13 测试了您的代码,它运行良好。 (我需要调整包名称并添加 SimpleBannerPositionEnum 定义)我只是在命令行中做了“ant all”,在平台更新期间做了“更新运行系统”(没有检查任何扩展)。我可以在后台创建 PromotionBannerCMSComponent 的实例。
您是否尝试过初始化并查看它是否适用于您?否则,您可能需要分享有关错误/堆栈跟踪的更多信息。
【讨论】:
【参考方案3】:原来我有一个旧的部署表与这个组件发生冲突,不知何故它在ant clean all
期间没有显示错误。
所以我在 HAC delete from ydeployments where typecode=XX;
中运行(XX 是在 HAC 中找到的类型代码)并以几乎相同的部署重新开始,除了我删除了 jaloclass 和部署表描述:
<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent">
<description>Promotion banner component</description>
<attributes>
<attribute qualifier="code" type="java.lang.String">
<persistence type="property"/>
<modifiers/>
<description>Banner name (not unique)</description>
</attribute>
<attribute qualifier="title" type="localized:java.lang.String">
<description>Title</description>
<modifiers read="true" write="true" search="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="position" type="SimpleBannerPositionEnum">
<description>Banner position</description>
<modifiers optional="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="altText" type="localized:java.lang.String">
<description>Banner alt text</description>
<modifiers optional="true" initial="true"/>
<persistence type="property"/>
</attribute>
<attribute qualifier="titleSecondary" type="localized:java.lang.String">
<description>Title secondary</description>
<persistence type="property" />
<modifiers />
</attribute>
<attribute qualifier="urlLoc" type="localized:java.lang.String">
<description>Banner url</description>
<persistence type="property" />
<modifiers />
</attribute>
</attributes>
</itemtype>
【讨论】:
以上是关于SAP Hybris 无法创建自定义横幅组件的主要内容,如果未能解决你的问题,请参考以下文章
java 调用 sap rfc函数 rfc函数是自定义的还是sap系统组件自带的