Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HybrisContextFactory-初始化全局应用程序上下文时出错_Java_Spring Mvc_Hybris - Fatal编程技术网

Java HybrisContextFactory-初始化全局应用程序上下文时出错

Java HybrisContextFactory-初始化全局应用程序上下文时出错,java,spring-mvc,hybris,Java,Spring Mvc,Hybris,我尝试将应用程序的版本从Hybris 4.8迁移到Hybris 5.6.0.5 当服务器启动时,我有以下异常: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'csTicketFacade' defined in class path resource [CoopAcceleratorFrontEndfacades-spring.xml]: Instantiation

我尝试将应用程序的版本从Hybris 4.8迁移到Hybris 5.6.0.5

当服务器启动时,我有以下异常:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'csTicketFacade' defined in class path resource [CoopAcceleratorFrontEndfacades-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class  [com.accenture.hybris.facades.customerservice.impl.CoopCSTicketFacade]: Constructor threw exception; nested exception is java.lang.NullPointerException

INFO   | jvm 1    | main    | 2016/01/20 11:41:54.777 | Caused by: java.lang.NullPointerException
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.790 |     at com.accenture.facades.common.FlexSelector.getPropertiesReader(FlexSelector.java:27)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.797 |     at com.accenture.hybris.facades.customerservice.impl.CoopCSTicketFacade$TicketFlexSelector.getCsAgentGroupUID(CoopCSTicketFacade.java:68)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.805 |     at com.accenture.hybris.facades.customerservice.impl.CoopCSTicketFacade$TicketFlexSelector.getCsAgentGroupModel(CoopCSTicketFacade.java:31)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.809 |     at com.accenture.hybris.facades.customerservice.impl.CoopCSTicketFacade.<init>(CoopCSTicketFacade.java:80)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.820 |     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.823 |     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.828 |     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.834 |     at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.838 |     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
INFO   | jvm 1    | main    | 2016/01/20 11:41:54.843 |     ... 35 more
spring的应用程序上下文为null。
如果有人有任何想法,请告诉我。

静态引用应用程序上下文不是一个好主意。 相反,正如@thijsraets建议的那样,您应该为
flexSelector
bean实现
ApplicationContextAware
。 例如:

这将确保在Spring连接bean时设置应用程序上下文


如果您在
FlexSelector
中有静态方法,并且需要其中的应用程序上下文,您应该始终通过
注册表.getApplicationContext()
调用在静态方法中动态查找它,而不是将其存储在静态变量中。

您真的只需要applicationContext对象吗?如果您只需要检索bean,可以按如下方式执行:

最终ManagerFactoryBean ManagerFactoryBean=(ManagerFactoryBean)注册表.getApplicationContext().getBean(“ManagerFactoryBean”)


我也在hybris工作,这就是我获取bean引用的方式。

你不能让类beanfactoryaware或applicationcontextaware吗?你能发布类CoopSticketFacade的内容吗?或者至少是它的主要部分?
protected static final ApplicationContext ctx = Registry.getApplicationContext();
public class FlexSelector implements ApplicationContextAware  {
    ApplicationContext context;
    public ApplicationContext getContext() {
        return context;
    }
    @Override
    public void setApplicationContext(ApplicationContext context)
            throws BeansException {
        this.context=context;
    }
    [...]
}