Hi
Got the following error randomly in production when using rich search. Sadly I’m unable to reproduce it in development environment, neither in a small project.
11:13:11.563 ERROR c.h.c.w.g.c.WebSuggestionField - Error in async search thread
com.google.common.util.concurrent.UncheckedExecutionException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.search_SideMenu' defined in com.haulmont.addon.search.web.configuration.MenuProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.haulmont.cuba.gui.components.mainwindow.SideMenu]: Factory method 'sideMenu' threw exception; nested exception is java.lang.NullPointerException
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2207)
at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
at com.haulmont.addon.search.strategy.SideMenuSearchStrategy.load(SideMenuSearchStrategy.java:45)
at com.haulmont.addon.search.presenter.impl.SearchPresenterImpl.load(SearchPresenterImpl.java:74)
at com.haulmont.addon.search.presenter.impl.SearchPresenterImpl.lambda$load$0(SearchPresenterImpl.java:67)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.haulmont.addon.search.presenter.impl.SearchPresenterImpl.load(SearchPresenterImpl.java:70)
at com.haulmont.addon.search.web.gui.components.WebRichSearch.search(WebRichSearch.java:119)
at com.haulmont.cuba.web.gui.components.WebSuggestionField.asyncSearch(WebSuggestionField.java:224)
at com.haulmont.cuba.web.gui.components.WebSuggestionField$1.run(WebSuggestionField.java:181)
at com.haulmont.cuba.web.gui.components.WebSuggestionField$1.run(WebSuggestionField.java:174)
at com.haulmont.cuba.web.gui.executors.impl.WebBackgroundWorker$WebTaskExecutor.call(WebBackgroundWorker.java:205)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.haulmont.cuba.web.gui.executors.impl.WebBackgroundWorker$WebTaskExecutor.lambda$startExecution$1(WebBackgroundWorker.java:376)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.search_SideMenu' defined in com.haulmont.addon.search.web.configuration.MenuProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.haulmont.cuba.gui.components.mainwindow.SideMenu]: Factory method 'sideMenu' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy401.getMenuItems(Unknown Source)
at com.haulmont.addon.search.strategy.loader.SideMenuDataLoader.<init>(SideMenuDataLoader.java:27)
at com.haulmont.addon.search.strategy.SideMenuSearchStrategy.lambda$load$0(SideMenuSearchStrategy.java:46)
at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
... 24 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.haulmont.cuba.gui.components.mainwindow.SideMenu]: Factory method 'sideMenu' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 40 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.haulmont.addon.search.web.configuration.MenuProvider.sideMenu(MenuProvider.java:28)
at com.haulmont.addon.search.web.configuration.MenuProvider$$EnhancerBySpringCGLIB$$e2bcf0e4.CGLIB$sideMenu$0(<generated>)
at com.haulmont.addon.search.web.configuration.MenuProvider$$EnhancerBySpringCGLIB$$e2bcf0e4$$FastClassBySpringCGLIB$$c0a4c06f.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.haulmont.addon.search.web.configuration.MenuProvider$$EnhancerBySpringCGLIB$$e2bcf0e4.sideMenu(<generated>)
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.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 41 common frames omitted
11:13:11.846 ERROR c.h.c.w.g.c.WebSuggestionField - Error in async search thread
com.google.common.util.concurrent.UncheckedExecutionException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.search_SideMenu' defined in com.haulmont.addon.search.web.configuration.MenuProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.haulmont.cuba.gui.components.mainwindow.SideMenu]: Factory method 'sideMenu' threw exception; nested exception is java.lang.NullPointerException
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2207)
at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4790)
at com.haulmont.addon.search.strategy.SideMenuSearchStrategy.load(SideMenuSearchStrategy.java:45)
at com.haulmont.addon.search.presenter.impl.SearchPresenterImpl.load(SearchPresenterImpl.java:74)
at com.haulmont.addon.search.presenter.impl.SearchPresenterImpl.lambda$load$0(SearchPresenterImpl.java:67)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.haulmont.addon.search.presenter.impl.SearchPresenterImpl.load(SearchPresenterImpl.java:70)
at com.haulmont.addon.search.web.gui.components.WebRichSearch.search(WebRichSearch.java:119)
at com.haulmont.cuba.web.gui.components.WebSuggestionField.asyncSearch(WebSuggestionField.java:224)
at com.haulmont.cuba.web.gui.components.WebSuggestionField$1.run(WebSuggestionField.java:181)
at com.haulmont.cuba.web.gui.components.WebSuggestionField$1.run(WebSuggestionField.java:174)
at com.haulmont.cuba.web.gui.executors.impl.WebBackgroundWorker$WebTaskExecutor.call(WebBackgroundWorker.java:205)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.haulmont.cuba.web.gui.executors.impl.WebBackgroundWorker$WebTaskExecutor.lambda$startExecution$1(WebBackgroundWorker.java:376)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.search_SideMenu' defined in com.haulmont.addon.search.web.configuration.MenuProvider: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.haulmont.cuba.gui.components.mainwindow.SideMenu]: Factory method 'sideMenu' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy401.getMenuItems(Unknown Source)
at com.haulmont.addon.search.strategy.loader.SideMenuDataLoader.<init>(SideMenuDataLoader.java:27)
at com.haulmont.addon.search.strategy.SideMenuSearchStrategy.lambda$load$0(SideMenuSearchStrategy.java:46)
at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4793)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
... 24 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.haulmont.cuba.gui.components.mainwindow.SideMenu]: Factory method 'sideMenu' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 40 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.haulmont.addon.search.web.configuration.MenuProvider.sideMenu(MenuProvider.java:28)
at com.haulmont.addon.search.web.configuration.MenuProvider$$EnhancerBySpringCGLIB$$e2bcf0e4.CGLIB$sideMenu$0(<generated>)
at com.haulmont.addon.search.web.configuration.MenuProvider$$EnhancerBySpringCGLIB$$e2bcf0e4$$FastClassBySpringCGLIB$$c0a4c06f.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.haulmont.addon.search.web.configuration.MenuProvider$$EnhancerBySpringCGLIB$$e2bcf0e4.sideMenu(<generated>)
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.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 41 common frames omitted
In the meantime I have extended SearchPresenterImpl.load
the following way to increase robustness.
/**
* in case of exception, catch it, log error and return empty stream
*/
@Override
protected Stream<SearchEntry> load(SearchContext context, SearchStrategy searchStrategy, String query) {
try {
return super.load(context, searchStrategy, query);
} catch (Exception e) {
log.error("Error executing search strategy : " + searchStrategy.name(), e);
return Stream.empty();
}
}
But I do not understand why sometimes MenuProvider.sideMenu()
(below) raises a NPE.
I upgraded from 6.10.13 to 6.10.15, maybe that’s the culprit.
@Bean("search_SideMenu")
@Scope(value = "prototype", proxyMode = ScopedProxyMode.INTERFACES)
public SideMenu sideMenu() {
return ((SideMenu) AppUI.getCurrent().getTopLevelWindow().getComponentNN("sideMenu"));
}
Regards
Michael