Reputation: 1690
I'm following a tutorial to manipulate nodeRef and content on Alfresco with JAVA. But when I try to define the serviceRegistry
,
ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
the beanFactory
is not initialized. And I already try much declarations but I can't initialise/declare this correctly. Can anyone help me?
I try:
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
ERROR:
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
Another way? How can I solve this?
Upvotes: 1
Views: 1116
Reputation: 1690
I solved it by substitute this: ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
for this:
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");
}
Upvotes: 1