cancel
Showing results for 
Search instead for 
Did you mean: 

NoSuchBeanDefinitionException

nanou
Champ in-the-making
Champ in-the-making
Hi,

I want to use a bean for jcr repository, but I get this error :

11 avr. 2008 17:37:39 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@b82368: display name [org.springframework.context.support.ClassPathXmlApplicationContext@b82368]; startup date [Fri Apr 11 17:37:39 CEST 2008]; root of context hierarchy
11 avr. 2008 17:37:39 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@b82368]: org.springframework.beans.factory.support.DefaultListableBeanFactory@14da8f4
11 avr. 2008 17:37:39 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@14da8f4: 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:29)
        at Test.main(Test.java:21)

In my application, code is :

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

and myContext.xml (I think it's this one which is bad written) contains :

<?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>

I've tried to replace
SpacesStore
with
myWorkspace
that I've created with alfresco web client, but it doesn't work.

Thanks in advance
7 REPLIES 7

janv
Employee
Employee
Looks like a typo, try replacing "=" with ":" so that:

ApplicationContext context = new ClassPathXmlApplicationContext("classpath*=alfresco/myContext.xml");
becomes:

ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:alfresco/myContext.xml");
Regards,
Jan

nanou
Champ in-the-making
Champ in-the-making
Hi,
I try to replace "=" with ":", but I get the same error.

Regards,
Nanou

nanou
Champ in-the-making
Champ in-the-making
I just paste class files from C:\alfresco\tomcat\webapps\alfresco\WEB-INF\classes to my netbeans project at C:\NetBeansProjects\myAlfresco\build\web\WEB-INF\classes and change "myContext.xml" by "application-context.xml" at :
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:alfresco/myContext.xml");
->
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:alfresco/application-context.xml");
and it works!

dinger
Champ in-the-making
Champ in-the-making
I think context files have to end with "context.xml"?

Rob

nanou
Champ in-the-making
Champ in-the-making
I don't really understand what you mean. Sorry I'm french…

Why context.xml must be "the last file" ?

Regards.

dinger
Champ in-the-making
Champ in-the-making
The name of the file must end with '-context.xml'. That is, context files must be of the format "*-context.xml". I know this is the case for Alfresco itself but I'm not sure in this case.

If you don't understand that then I can try and do a french translation  :shock:

Rob

nanou
Champ in-the-making
Champ in-the-making
Ok, thanks well !