Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP / Controller not found for custom component in Hybris addon

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:

  • Created component in -items.xml inheriting from SimpleCMSComponent
  • Created controller inheriting from AbstractCMSController,
  • Created JSP in addon folder,
  • Created component and added to page slot via Imped,
  • @Controller has the name equal to component + “Controller”

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

like image 549
Joao Sousa Avatar asked Oct 25 '25 05:10

Joao Sousa


1 Answers

Make sure

  • Your controller should extends 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

like image 132
HybrisHelp Avatar answered Oct 27 '25 01:10

HybrisHelp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!