I want to access into the repository JCR of alfresco in the start of alfresco server .I do this :in web.xml I add :
<servlet>
<servlet-name>SpaceRepository</servlet-name>
<servlet-class>fr.company.alfresco.servlet.SpaceRepositoryServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
after that i implement My servlet :
public class SpaceRepositoryServlet extends HttpServlet
{
final static Logger logger=Logger.getLogger(SpaceRepositoryServlet.class);
public void init(ServletConfig config) throws ServletException
{
logger.info("SpaceRepository Engine started begin!! ");
try{
createSpace();
}
catch (Exception e) {
logger.error("Creating Space Batch Failed !! ", e);
}
logger.info("SpaceRepository Engine started End!! ");
}
@Override
public void destroy() {
logger.info("SpaceRepository Engine stopped begin!! ");
logger.info("SpaceRepository Engine stopped End!! ");
}
The code of method createSpace(); is :
private void createSpace() throws Exception{
ApplicationContext context = ApplicationContextHelper.getApplicationContext();
Repository repository = (Repository)context.getBean("JCR.Repository");
…..
…..
}
I have an error in the first line : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workflowScheduler' defined in class path resource [alfresco/bootstrap-context.xml]: Cannot resolve reference to bean 'jbpm_template' while setting bean property 'JBPMTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpm_template' defined in class path resource [alfresco/workflow-context.xml]: Cannot resolve reference to bean 'jbpm_configuration' while setting constructor argument with index 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpm_configuration' defined in class path resource [alfresco/workflow-context.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for key jbpm_configurationNote:I try also : ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");and WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());but no way .Can you help me to access in to applicationContext of alfresco from an servlet Thanks