Reputation: 501
I’m running Hybris 6.6 and are building a new addon, that is basically a controller and corresponding JSP. During runtime however, Hybris isn’t finding the controller bean and searches for JSP in the storefront folder (it’s not there, since the JSP is in the storefront addon folder).
I created the addon using extgen, and then installed it in the storefront using also ant.
Steps:
I’ve debuged the code, and when Hybris tries to find if there is a controller via getBeanFactory().contains(controller) it returns false. If I look at the bean list that the bean factory returns, the bean for the controller is not there.
Any clues on what’s happening? I’ve even tried to create the controller bean explicitly on the -web-spring.xml but doesn’t change anything.
Thank you
Upvotes: 4
Views: 3430
Reputation: 5810
Make sure
GenericCMSAddOnComponentController
or AbstractCMSAddOnComponentController
for the compoent inside addon.Annotate the Controller with
@Controller(YourComponentController)
@RequestMapping(value="/view/YourComponentController")
Add your jsp to *addon/web/webroot/*/view/*/cms/yourcomponentname.jsp
.
Refer getView method of AbstractCMSAddOnComponentController for the path
*-web-spring.xml
should be in resource folder/path
component scan should be added for your controller in *-web-spring.xml
<context:component-scan base-package="my.path.controllers"/>
*-web-spring.xml
should be configured in additionalWebSpringConfigs properties. Refer your addon project.properties
like
myCustomstorefront.additionalWebSpringConfigs.MyAddonName=classpath:/XXX/web/spring/*-web-spring.xml
Upvotes: 7
Reputation: 506
In addition to the excellent instructions by HybrisHelp, it's likely that others coming across this question need to add this to the *-web-spring.xml
scope-resolver="de.hybris.platform.spring.IgnoreTenantScopeMetadataResolver"
so it looks like
<context:component-scan base-package="my.path.controllers" scope-resolver="de.hybris.platform.spring.IgnoreTenantScopeMetadataResolver" />
Only with this attribute, the controller was loaded for me.
Upvotes: 0