AnsweredAssumed Answered

Can't find 'application-context.xml'

Question asked by doblek on Oct 17, 2006
Latest reply on Mar 25, 2009 by atsjzh
Hi,

I have the following code inside a portlet:

ApplicationContext app_ctx = ApplicationContextHelper.getApplicationContext();

//Getting Service Registry
final ServiceRegistry reg = (ServiceRegistry) app_ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

if (reg.isServiceProvided(ServiceRegistry.NODE_SERVICE)){
     //Create a user transaction explicitly
     TransactionService trx_srvc = reg.getTransactionService();
     TransactionWork trx_wrk = new TransactionWork(){
           public NodeRef doWork() throws Exception{
                 //Get Node Service from registry
                 NodeService node_srvc = reg.getNodeService();
                 //Authenticate as admin
                 AuthenticationService authenticationService = reg.getAuthenticationService();
                 authenticationService.authenticate("admin", "admin".toCharArray());
                 //Create store
                 StoreRef users_store = CreateStore(node_srvc, store_name);
                 //Crete folder in store
                 NodeRef folder_ref = AddFolderToStore(node_srvc, users_store, folder_name);
                 return folder_ref;
          }
     };
TransactionUtil.executeInUserTransaction(trx_srvc, trx_wrk);
}

But I think it crashes when creating the first ApplicationContext object, because I get the following error stack:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [alfresco/application-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist
java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist
   at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:167)
   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
   at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
   at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:81)
   at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:269)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
   at org.alfresco.util.ApplicationContextHelper.getApplicationContext(ApplicationContextHelper.java:40)
   at p2.processAction(p2.java:295)

However, I have this application-context.xml under the following directory: $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco. And also, it's referenced in Alfresco's web.xml file as value for contextConfigLocation parameter.

What am I doing wrong?

Any help would be very much appreciated.

Thanks in advance,
Enrique

Outcomes