cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Null pointer exception on overriding assistedServiceService

0 Kudos

After overriding OOB assistedServiceService I am getting NPE in OOB class 'DefaultAssistedServiceFacade.java' for line assistedServiceService.getAsmSession().

To override service I have followed below steps.

1- Declared bean in customextension-core-spring.xml file as below

    <alias name="defaultcustomAssistedServiceService" alias="assistedServiceService"/>
    <bean id="defaultcustomAssistedServiceService" class="com.custom.core.services.impl.DefaultCustomAssistedServiceService" parent ="defaultAssistedServiceService"><br>        <property name="flexibleSearchService" ref="flexibleSearchService"/>
    </bean>

2- Created a custom class overriding OOB defaultCustomAssistedServiceService class

public class DefaultCustomAssistedServiceService extends DefaultAssistedServiceService implements CustomAssistedServiceService{
	private FlexibleSearchService flexibleSearchService;
	@Override
    public CartModel getCartByCode(final String cartCode) {//logic}
}
//Getter Setter
public FlexibleSearchService getFlexibleSearchService() {
		return flexibleSearchService;}
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService) {
		this.flexibleSearchService = flexibleSearchService;}

Since Object of assistedServiceService is already been used in other OOB classes, So wherever its been called it is giving NPE. Am I missing something in service overriding?

Please note OOB assistedServiceService is defined in OOB extension 'assistedServiceService' in file assistedserviceservices-spring.xml as

<alias name="defaultAssistedServiceService" alias="assistedServiceService"/>
    <bean id="defaultAssistedServiceService" class="de.hybris.platform.assistedserviceservices.impl.DefaultAssistedServiceService">
        <property name="modelService" ref="modelService"/>
        <property name="userService" ref="userService"/>
        <property name="baseSiteService" ref="baseSiteService"/>
        <property name="cartService" ref="cartService"/>
        <property name="sessionService" ref="sessionService"/>
        <property name="flexibleSearchService" ref="flexibleSearchService"/>
        <property name="pagedFlexibleSearchService" ref="pagedFlexibleSearchService"/>
        <property name="commerceCartService" ref="commerceCartService"/>
        <property name="customerAccountService" ref="customerAccountService"/>
        <property name="commonI18NService" ref="commonI18NService"/>
        <property name="timeService" ref="timeService"/>
    </bean><br>

Here are exception logs

SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [Error while processing internal filterchain. Exception occurred at chain position: 11 of 17. Current filter: 'FilterChainProxy[Filter Chains: [[ Ant [pattern='/_ui/**'], []], [ Ant [pattern='/checkout/**'], [org.springframework.security.web.access.channel.ChannelProcessingFilter@8e8e0bf, org.springframework.security.web.context.SecurityContextPersistenceFilter@56aa2d5b, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6f7ad281, org.springframework.security.web.header.HeaderWriterFilter@69e3c7f, org.springframework.security.web.authentication.logout.LogoutFilter@493cc90b, org.springframework.security.web.csrf.CsrfFilter@4efbf582, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@77acc806, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@266f48, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2ffd8ad6, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3e3b2d4e, org.springframework.security.web.session.SessionManagementFilter@2f463e77, org.springframework.security.web.access.ExceptionTranslationFilter@1c2958f8, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5fc1da91]], [ com.custom.equipment.security.ExcludeUrlRequestMatcher@146854bb, [org.springframework.security.web.access.channel.ChannelProcessingFilter@5f9674ff, org.springframework.security.web.context.SecurityContextPersistenceFilter@5900dd6f, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@43c5114e, org.springframework.security.web.header.HeaderWriterFilter@155e4801, org.springframework.security.web.authentication.logout.LogoutFilter@493cc90b, org.springframework.security.web.csrf.CsrfFilter@7903e7d9, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@26b7b633, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4d138cca, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2a6adb29, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4cb1cc92, org.springframework.security.web.session.SessionManagementFilter@57acfd19, org.springframework.security.web.access.ExceptionTranslationFilter@6084efa, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7ac76e81]], [ org.springframework.security.web.util.matcher.RegexRequestMatcher@28525fad, [org.springframework.security.web.access.channel.ChannelProcessingFilter@78d48931, org.springframework.security.web.context.SecurityContextPersistenceFilter@2a451d1b, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@74017b66, org.springframework.security.web.header.HeaderWriterFilter@4e94ed7c, org.springframework.security.web.csrf.CsrfFilter@12d5789e, org.springframework.security.web.authentication.logout.LogoutFilter@107a021a, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@6fdf8138, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6c96eb2, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@3fe1f77d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@7fcb4849, org.springframework.security.web.session.SessionManagementFilter@6c0ed0c9, org.springframework.security.web.access.ExceptionTranslationFilter@21ff9f04, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1195de59]]]]'!; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
        at de.hybris.platform.assistedservicefacades.impl.DefaultAssistedServiceFacade.getAsmSession(DefaultAssistedServiceFacade.java:725)
        at de.hybris.platform.assistedservicefacades.impl.DefaultAssistedServiceFacade.isAssistedServiceModeLaunched(DefaultAssistedServiceFacade.java:140)
        at com.custom.asm.aspect.ChannelDecisionAspect.isAssistedServiceMode(ChannelDecisionAspect.java:87)
        at com.custom.asm.aspect.ChannelDecisionAspect.decideAround(ChannelDecisionAspect.java:53)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671)
        at org.springframework.security.web.access.channel.ChannelDecisionManagerImpl$$EnhancerBySpringCGLIB$$67fa9de1.decide(<generated>)
        at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:150)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at com.custom.equipment.filters.FileUploadFilter.doFilterInternal(FileUploadFilter.java:51)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at com.custom.equipment.filters.UrlEncoderFilter.doFilterInternal(UrlEncoderFilter.java:85)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at com.custom.equipment.filters.StorefrontFilter.doFilterInternal(StorefrontFilter.java:74)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at com.custom.equipment.filters.cms.CMSSiteFilter.doFilterInternal(CMSSiteFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at com.custom.equipment.filters.RequestLoggerFilter.doFilterInternal(RequestLoggerFilter.java:71)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at com.custom.equipment.filters.AcceleratorAddOnFilter.doFilter(AcceleratorAddOnFilter.java:90)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at de.hybris.platform.servicelayer.web.WebAppMediaFilter.doFilter(WebAppMediaFilter.java:128)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at de.hybris.platform.servicelayer.web.SessionFilter.doFilter(SessionFilter.java:99)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at de.hybris.platform.servicelayer.web.Log4JFilter.doFilter(Log4JFilter.java:44)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at de.hybris.platform.servicelayer.web.session.HybrisSpringSessionFilter.doFilter(HybrisSpringSessionFilter.java:69)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:297)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.processStandardFilterChain(AbstractPlatformFilterChain.java:206)
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.doFilterInternal(AbstractPlatformFilterChain.java:183)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at com.custom.equipment.filters.UrlPathFilter.doFilterInternal(UrlPathFilter.java:82)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at com.custom.equipment.filters.AcceleratorAddOnFilter.doFilter(AcceleratorAddOnFilter.java:90)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at de.hybris.platform.servicelayer.web.XSSFilter.processPatternsAndDoFilter(XSSFilter.java:358)
        at de.hybris.platform.servicelayer.web.XSSFilter.doFilter(XSSFilter.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:750)
romitchhabra
Participant
0 Kudos

Hi Naved, Can you please share the exception log.

0 Kudos

romitchhabra updated question with logs

Accepted Solutions (0)

Answers (1)

Answers (1)

Error is resolved now. Had to call a super method in one of facade, where I was setting the service object.

public void setAssistedServiceService(CustomAssistedServiceService assistedServiceService) {
		super.setAssistedServiceService(assistedServiceService);
		this.assistedServiceService = assistedServiceService;
	}