错误 beanFactory/ApplicationContext - JAVA
Error beanFactory/ApplicationContext - JAVA
我正在跟随 tutorial 使用 JAVA 操作 nodeRef 和 Alfresco 上的内容。但是当我尝试定义 serviceRegistry
,
ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
beanFactory
未初始化。我已经尝试了很多声明,但我不能 initialise/declare 正确。谁能帮帮我?
我试试:
ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/web-client-application-context.xml");
ServiceRegistry serviceRegistry = (ServiceRegistry) appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
web-client-application-context.xml:
https://github.com/Alfresco/community-edition/blob/master/projects/web-client/config/alfresco/web-client-application-context.xml
错误:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'GlobalAuthenticationFilter' defined in class
path resource [alfresco/web-client-application-context.xml]: Cannot
resolve reference to bean 'Authentication' while setting bean property
'applicationContextManager'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'Authentication' is defined
另一种方式?我该如何解决这个问题?
我用这个替代解决了这个问题:ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_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");
}
我正在跟随 tutorial 使用 JAVA 操作 nodeRef 和 Alfresco 上的内容。但是当我尝试定义 serviceRegistry
,
ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
beanFactory
未初始化。我已经尝试了很多声明,但我不能 initialise/declare 正确。谁能帮帮我?
我试试:
ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/web-client-application-context.xml");
ServiceRegistry serviceRegistry = (ServiceRegistry) appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
web-client-application-context.xml: https://github.com/Alfresco/community-edition/blob/master/projects/web-client/config/alfresco/web-client-application-context.xml
错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GlobalAuthenticationFilter' defined in class path resource [alfresco/web-client-application-context.xml]: Cannot resolve reference to bean 'Authentication' while setting bean property 'applicationContextManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'Authentication' is defined
另一种方式?我该如何解决这个问题?
我用这个替代解决了这个问题:ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_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");
}