错误beanFactory/ApplicationContext-JAVA
我下面介绍一个使用JAVA在Alfresco上操作nodeRef和内容的方法。但是当我试图定义错误beanFactory/ApplicationContext-JAVA,java,spring,spring-mvc,javabeans,alfresco,Java,Spring,Spring Mvc,Javabeans,Alfresco,我下面介绍一个使用JAVA在Alfresco上操作nodeRef和内容的方法。但是当我试图定义serviceRegistry时 ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY); beanFactory未初始化。我已经尝试了很多声明,但我不能正确初始化/声明。有人能帮我吗 我尝试: ApplicationContext ap
serviceRegistry
时
ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
beanFactory
未初始化。我已经尝试了很多声明,但我不能正确初始化/声明。有人能帮我吗
我尝试:
ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/web-client-application-context.xml");
ServiceRegistry ServiceRegistry=(ServiceRegistry)appContext.getBean(ServiceRegistry.SERVICE\u注册表)
web客户端应用程序上下文.xml:
错误:
org.springframework.beans.factory.BeanCreationException:错误
正在创建类中定义的名为“GlobalAuthenticationFilter”的bean
路径资源[alfresco/web客户端应用程序上下文.xml]:无法
设置bean属性时解析对bean“身份验证”的引用
“applicationContextManager”;嵌套异常是
org.springframework.beans.factory.noSuchBean定义异常:否
已定义名为“身份验证”的bean
另一种方式?如何解决这个问题?我通过替换以下内容来解决:
ServiceRegistry ServiceRegistry=(ServiceRegistry)beanFactory.getBean(ServiceRegistry.SERVICE\u REGISTRY)代码>
为此:
protected ServiceRegistry getServiceRegistry() {
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
if (config != null) {
// Fetch the registry that is injected in the activiti spring-configuration
ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
if (registry == null) {
throw new RuntimeException("Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
}
return registry;
}
throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
}
建议您使用alfresco/application context.xml
作为应用程序上下文配置,或者更好地使用Spring依赖项注入来获取所有必需的服务bean。