0

I've coded two model files. For some associations both models have reference to a type in the other file. Also I updated depends-on tag (one model depends on the other) of beans in context file (I know depends-on tag refers to bean which is already created). It is throwing error when I run in tomcat.

(1) Is there a way to achieve the above without error?

(2) If not, put all types in one model file, is it what I need to do?

Here is the bean declaration in abc-model-context.xml

<bean id="exampleOne.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
    <property name="models">
        <list>                
            <value>alfresco/extension/model/defModel.xml</value>    
            <value>alfresco/extension/model/abcModel.xml</value>
            <value>alfresco/extension/model/ghiModel.xml</value>
        </list>
    </property>
</bean>

Here is the stack trace of the error.

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleOne.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\abc-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 00150001 Could not import bootstrap model alfresco/extension/model/defModel.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 00150001 Could not import bootstrap model alfresco/extension/model/defModel.xml at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:158) at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:105) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 27 more Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 00150000 Failed to compile model def:defModel at org.alfresco.repo.dictionary.CompiledModel.(CompiledModel.java:108) at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:163) at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModelImpl(DictionaryDAOImpl.java:311) at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:294) at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:154) ... 35 more Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.exampleOne.org/model/abc/1.0 cannot be imported as it is not defined (with prefix abc at org.alfresco.repo.dictionary.CompiledModel.createLocalPrefixResolver(CompiledModel.java:206) at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:130) at org.alfresco.repo.dictionary.CompiledModel.(CompiledModel.java:88) ... 39 more

Nikhil A A
  • 441
  • 1
  • 4
  • 17
  • I don't know what error you are seeing so I can't help. – Jeff Potts Jan 15 '14 at 00:12
  • I've posted the bean declaration in context file and error stack trace from log file – Nikhil A A Jan 15 '14 at 05:03
  • You say you have 2 model files but list 3 in the context.xml? You have an abc:assoc that refers to a def:type and a def:assoc that refers to a abc:type? Please clarify the type/assoc locations using namespace prefixes. – Florian Jan 15 '14 at 12:59

2 Answers2

2

I suspect your defModel.xml file is either malformed or not valid. Make sure that when you open it in an XML-aware editor that it does not complain. You might also want to check it against modelSchema.xsd which resides in $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes/alfresco/model.

Jeff Potts
  • 10,468
  • 17
  • 40
  • I took the suggest given in Alfresco forum "you can not have two models that depend on one another in a cirular way. But you also do not need to move alls types into one model file. It should be enough to move the associations to one file, so you have one model depend on the other without the circular route. It should be easy to move the association - you just need to update the name and target class". It is working for me now. Thank you Jeff – Nikhil A A Jan 16 '14 at 11:47
1

Have a look at http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Model_Bootstrapping

The dictionary bootstrap bean supports a list property for models:

  <property name="models">
        <list>
            <value>my/customModel1.xml</value>
            <value>my/customModel2.xml</value>
        </list>
    </property>

Hence, the easiest fix is to use just one bean with both models.

Andreas Steffan
  • 6,039
  • 2
  • 23
  • 25