cancel
Showing results for 
Search instead for 
Did you mean: 

'No bean named 'dictionaryModelBootstrap' is defined&qu

jackpark
Champ in-the-making
Champ in-the-making
In my extension file ts-model-context.xml, I defined this bean
    <bean id="extension.TS_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/ts-Model.xml</value>
            </list>
        </property>
    </bean>

dictionaryModelBootstrap in core-services-context.xml
The error message – quoted in the subject line – suggests the system is trying to load my extension before loading the core beans. What am I missing here?

Thanks
Jack
8 REPLIES 8

davidc
Star Contributor
Star Contributor
In which environment are you initialising the Repository?  The Alfresco Web Application or your own custom application.

jackpark
Champ in-the-making
Champ in-the-making
That's interesting! I boot your servlet first, then mine, but it might well be that alfresco has yet to complete its initialization. One has to wonder what sort of workaround is available for this.

Thanks!

davidc
Star Contributor
Star Contributor
I'm not sure I fully understand how you're initialising Alfresco, but you should only need to initialise once for your web application.  Normally, there's a single Spring listener configured in web.xml which initialises from the list of *-context.xml files listed in the contextConfigLocation context-param.

That's independent of how many servlets are registered.

jackpark
Champ in-the-making
Champ in-the-making
Thanks.

The open question is this: when is it that the spring initializer runs?

I can say this about my code. I have an init() routine in my servlet, which loads as #2 during tomcat startup. In that init() routine, I call my application which asks alfresco for a repository instance. That's the time I get the error; it seems that alfresco has been asked to find an instance of my context.xml file, and that's when it asks for the parent bean in my file, which does not (yet) exist.

Is there some kind of "alfrescoHasInitialized" event I can subscribe to to know when to initialize my application?

Thanks again.

gavinc
Champ in-the-making
Champ in-the-making
You should probably create your own context listener and register it in web.xml. If you add yours last in the list then you'll know all the Spring/Alfresco init would have completed.

For example:


<listener>
   <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
   <listener-class>org.alfresco.web.app.ContextListener</listener-class>
</listener>

<listener>
   <listener-class>your.ContextListener</listener-class>
</listener>

jackpark
Champ in-the-making
Champ in-the-making
Wow! I was prepared all day to raise a toast to a cool idea. I added a listener to the end of the listener chain and still get the same error, looking like what I paste in below.  This tells me that the core dictionary beans have yet to be defined.

My code to fire up a repository looks like this:

             ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/extension/ts-model-context.xml");
             repository = (Repository)context.getBean("JCR.Repository");

This code was cloned from the wiki example and substituted a reference to my model-context.xml file. The system is "tossing its bisquits"  when firing up ClassPathXmlApplicationContext.

Somehow, the rest of Alfresco has yet to come alive, even though my context listener exists at the bottom of the listener chain in web.xml.

What am I missing?
Many thanks.
Jack
java.lang.RuntimeException: org.nex.ts.TopicSpacesException: org.nex.ts.TopicSpacesException: org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'extension.TS_dictionaryBootstrap' defined in class path resource [alfresco/extension/ts-model-context.xml]: Could not resolve parent bean definition 'dictionaryModelBootstrap'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dictionaryModelBootstrap' is defined

jackpark
Champ in-the-making
Champ in-the-making
I got an idea from looking (again) at the Repository Java API, that suggested a way to fire up Alfresco context. I added the following code in front of my code that was crashing trying to make spring beans:

System.out.println("AlfrescoServletContextListener.contextInitialized 1");
ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/application-context.xml");

That code is right out of this page:
http://wiki.alfresco.com/wiki/Alfresco_Content_Management_Java_API
for getting an instance of the Service Registry. I thought it might provoke a full initialization of Alfresco. Didn't happen like that. Here's the trace…Can anyone explain why this fails?

Thank you.
Jack

AlfrescoServletContextListener.contextInitialized 1

18:25:47,750 ERROR [[Catalina].[localhost].[/alfresco]] Exception sending contex
t initialized event to listener instance of class org.nex.ts.smp.AlfrescoServlet
ContextListener
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'ftsIndexerTrigger' defined in class path resource [alfresco/scheduled-jo
bs-context.xml]: Initialization of bean failed; nested exception is org.quartz.O
bjectAlreadyExistsException: Unable to store Job with name: 'ftsIndexerJobDetail
' and group: 'DEFAULT', because one already exists with this identification.
org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'ftsInde
xerJobDetail' and group: 'DEFAULT', because one already exists with this identif
ication.

davidc
Star Contributor
Star Contributor
You do not need to construct a ClassPathXmlApplicationContext.  A Spring context is created for you by the Spring listener in web.xml.

In your servlet you can get access to the ApplicationContext using something like:

WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);

where sc is your ServletContext.

Then you issue:

Repsitory repository = (Repository)wc.getBean("JCR.Repository");