cancel
Showing results for 
Search instead for 
Did you mean: 

Can't find 'application-context.xml'

doblek
Champ in-the-making
Champ in-the-making
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
2 REPLIES 2

doblek
Champ in-the-making
Champ in-the-making
I think I was in a mistake since I invoked those commands from a portlet application that cannot see Alfresco's context in Tomcat…

I will try with Web Services 😃

Thanks.

atsjzh
Champ in-the-making
Champ in-the-making
Hallo
i have installed trial version of alfresco and i am trying to run it but i cant. I have recieved also error in log -
18:16:52,984 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
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
Caused by: java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist

and actually i cant find xml file named application-context.xml in whole alfresco folder that was installed. How is it possible and where can i find this file?

thanks in advance