Skip to Content
author's profile photo Former Member
Former Member

How can we access Service Layer methods from our own hmc extension?

Hi All,

I have a requirement of creating a link through hmc based on the values given by the hmc user. I am using the create action and in beforecreate() method I am using the values entered by the user. In my scenario, user is entering product, plan, promotion code. Now depending on the promotion code I need to fetch ProductPromotionModel or AbstractPromotionModel and to fetch this i am calling getPromotionForCode() method of DefaultPromotionDao. Now this method internally calls doSearch which calls search() method of AbstractItemDao class which uses flexibleSearchService instance to call search() method. I don't know why Spring Dependency injection is not working in my own hmc extension and I am not sure whether it works on hmc extension or not? Since dependency injection is not working, i am getting NullPointerExcepttion at this point.

Now another way around, I created my own service class and dao class in myhmc extension to create the objects explicitly through new operator. Then it worked for flexibleSearchService but then internally it fails in getJaloResult() method of DefaultFlexibleSearchService class in which it calls getSessionService() method. Now please tell me the solution for this. I am in urgent need for this solution.

Please see the logs for the second case in which I am using my own Dao:

java.lang.NullPointerException at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.getJaloResult(DefaultFlexibleSearchService.java:363) at de.hybris.platform.servicelayer.search.impl.DefaultFlexibleSearchService.search(DefaultFlexibleSearchService.java:164) at com.vivo.vivohmcextension.hmc.ViVoPromotionsDaoImpl.getPromotionForCode(ViVoPromotionsDaoImpl.java:27) at com.vivo.vivohmcextension.hmc.CampaignUrlAction.beforeCreate(CampaignUrlAction.java:99) at de.hybris.platform.hmc.util.action.CreateAction.perform(CreateAction.java:184) at de.hybris.platform.hmc.generic.organizer.OrganizerItemCreatorChip.performSave(OrganizerItemCreatorChip.java:121) at de.hybris.platform.hmc.ItemChip.save(ItemChip.java:224) at de.hybris.platform.hmc.generic.organizer.OrganizerCreatorSaveAndCopyToolbarActionChip.perform(OrganizerCreatorSaveAndCopyToolbarActionChip.java: at de.hybris.platform.hmc.AbstractToolbarActionChip.processEvents(AbstractToolbarActionChip.java:131) at de.hybris.platform.hmc.webchips.DisplayState.dispatchEvents(DisplayState.java:634) at de.hybris.platform.hmc.webchips.DisplayState.extractEventsFromParameters(DisplayState.java:443) at de.hybris.platform.hmc.webchips.DisplayState.processEvents(DisplayState.java:354) at de.hybris.platform.hmc.webchips.MasterServlet.process(MasterServlet.java:193) at de.hybris.platform.hmc.webchips.MasterServlet.doPost(MasterServlet.java:83) at javax.servlet.http.HttpServlet.service(HttpServlet.java:646) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:256) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$StatisticsGatewayFilter.doFilter(AbstractPlatformFilterChain.java:345) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.SecureMediaFilter.doFilter(SecureMediaFilter.java:97) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.DynamicCatalogVersionActivationFilter.doFilter(DynamicCatalogVersionActivationFilter.java:93) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.DataSourceSwitchingFilter.doFilter(DataSourceSwitchingFilter.java:73) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.SessionFilter.doFilter(SessionFilter.java:73) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.RedirectWhenSystemIsNotInitializedFilter.doFilter(RedirectWhenSystemIsNotInitializedFilter.java:104) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.DynamicTenantSwitchingFilter.doFilterInternal(DynamicTenantSwitchingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.Log4JFilter.doFilter(Log4JFilter.java:47) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.doFilterInternal(AbstractPlatformFilterChain.java:156) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at de.hybris.platform.servicelayer.web.XSSFilter.doFilter(XSSFilter.java:230) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

And in my first scenario in which i am using OOTB DefaultPromtionsDao I am getting below logs:

                             java.lang.NullPointerException
 at de.hybris.platform.servicelayer.internal.dao.AbstractItemDao.search(AbstractItemDao.java:70)
 at de.hybris.platform.acceleratorservices.promotions.dao.impl.DefaultPromotionsDao.doSearch(DefaultPromotionsDao.java:58)
 at de.hybris.platform.acceleratorservices.promotions.dao.impl.DefaultPromotionsDao.getPromotionForCode(DefaultPromotionsDao.java:39)
 at com.vivo.vivohmcextension.hmc.CampaignUrlAction.beforeCreate(CampaignUrlAction.java:99)
 at de.hybris.platform.hmc.util.action.CreateAction.perform(CreateAction.java:184)
 at de.hybris.platform.hmc.generic.organizer.OrganizerItemCreatorChip.performSave(OrganizerItemCreatorChip.java:121)
 at de.hybris.platform.hmc.ItemChip.save(ItemChip.java:224)
 at de.hybris.platform.hmc.generic.organizer.OrganizerCreatorSaveAndCopyToolbarActionChip.perform(OrganizerCreatorSaveAndCopyToolbarActionChip.java:49)
 at de.hybris.platform.hmc.AbstractToolbarActionChip.processEvents(AbstractToolbarActionChip.java:131)
 at de.hybris.platform.hmc.webchips.DisplayState.dispatchEvents(DisplayState.java:634)
 at de.hybris.platform.hmc.webchips.DisplayState.extractEventsFromParameters(DisplayState.java:443)
 at de.hybris.platform.hmc.webchips.DisplayState.processEvents(DisplayState.java:354)
 at de.hybris.platform.hmc.webchips.MasterServlet.process(MasterServlet.java:193)
 at de.hybris.platform.hmc.webchips.MasterServlet.doPost(MasterServlet.java:83)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:256)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$StatisticsGatewayFilter.doFilter(AbstractPlatformFilterChain.java:345)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.SecureMediaFilter.doFilter(SecureMediaFilter.java:97)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.DynamicCatalogVersionActivationFilter.doFilter(DynamicCatalogVersionActivationFilter.java:93)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.DataSourceSwitchingFilter.doFilter(DataSourceSwitchingFilter.java:73)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.SessionFilter.doFilter(SessionFilter.java:73)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.RedirectWhenSystemIsNotInitializedFilter.doFilter(RedirectWhenSystemIsNotInitializedFilter.java:104)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.DynamicTenantSwitchingFilter.doFilterInternal(DynamicTenantSwitchingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.Log4JFilter.doFilter(Log4JFilter.java:47)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226)
 at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.doFilterInternal(AbstractPlatformFilterChain.java:156)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at de.hybris.platform.servicelayer.web.XSSFilter.doFilter(XSSFilter.java:230)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Unknown Source)



Thanks in advance..:)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 18, 2015 at 03:05 AM

    Hi Chetan, You can try this syntax:

     final ModelService modelService = (ModelService) Registry.getApplicationContext().getBean("modelService");
    
       
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2015 at 02:29 PM

    Hi,

    Thanks for the help..

    I have found the solution. hmc works on jalo sessions. I have used JaloSession.getCurrentSession().getFlexibleSearch().search() method to to fix my prroblem.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.