AnsweredAssumed Answered

application context

Question asked by nanou on Apr 15, 2008
Latest reply on Apr 16, 2008 by nanou
Hi,
I would like to get the context of my application but I don't understand where to put xml files.

This is my code :

ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:Alfresco/myContext.xml");
this.repository = (Repository)context.getBean("JCR.Repository");

For this time myContext.xml is defined in the default Alfresco workspace but I get the same error when I move or remove this file.

My error :
15 avr. 2008 10:00:03 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@100ab23: display name [org.springframework.context.support.ClassPathXmlApplicationContext@100ab23]; startup date [Tue Apr 15 10:00:03 CEST 2008]; root of context hierarchy
15 avr. 2008 10:00:03 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@100ab23]: org.springframework.beans.factory.support.DefaultListableBeanFactory@5329c5
15 avr. 2008 10:00:03 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5329c5: defining beans []; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'JCR.Repository' is defined
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:968)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
        at MyBeanImpl.<init>(MyBeanImpl.java:31)
        at Test.main(Test.java:21)

Main error :
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'JCR.Repository' is defined

myContext.xml :
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <bean id="JCR.Repository" class="org.alfresco.jcr.repository.RepositoryImpl" init-method="init">
        <property name="serviceRegistry"><ref bean="ServiceRegistry"/></property>
        <property name="importerComponent"><ref bean="importerComponent"/></property>
        <property name="defaultWorkspace"><value>SpacesStore</value></property>
    </bean>
    <bean id="JCR.DictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/model/jcrModel.xml</value>
            </list>
        </property>
    </bean>  
</beans>

Thanks in advance,
Regards.

Outcomes