cancel
Showing results for 
Search instead for 
Did you mean: 

Importing a custome content model

d_franz
Champ on-the-rise
Champ on-the-rise
I have two content models. Both are working fine. Now I want to add some Aspects to a content type out of one of these models inside the other.
But a usual import of this namespace is not working.

That are the begin of Model 1:

<model name="base:archiv" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <description>BASE-Archiv Model</description>
    <author>DF</author>
    <version>1.0</version>
    <!– import base models –>
    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />

    </imports>
    <namespaces>
        <!– Define a Namespace for new definitions –>
        <namespace uri="base.contenmodel" prefix="base" />
    </namespaces>


The beginn of Model 2 that I whant to import to Model 1:

<model name="marker:archiv" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <description>Marker for base-Archiv</description>
    <author>DF</author>
    <version>1.0</version>
    <!– import base models –>
    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
    </imports>
    <namespaces>
        <!– Define a Namespace for new definitions –>
        <namespace uri="marker.new.model" prefix="marker" />
    </namespaces>


My last try on Model 1 was as follows:

<model name="base:archiv" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <description>BASE-Archiv Model</description>
    <author>DF</author>
    <version>1.0</version>
    <!– import base models –>
    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
        <import uri="marker.new.model" prefix="marker" />

    </imports>
    <namespaces>
        <!– Define a Namespace for new definitions –>
        <namespace uri="base.contenmodel" prefix="base" />
    </namespaces>


The Errors in Log are as follows:

14:46:40,301 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\custom-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 03110001 Could not import bootstrap model alfresco/extension/basearchiv.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:4791)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
   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:618)
   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
   at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
   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:1110)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
   at java.lang.Thread.run(Thread.java:722)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 03110001 Could not import bootstrap model alfresco/extension/basearchiv.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:601)
   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: 03110000 Failed to compile model base:archiv
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:108)
   at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:163)
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModelImpl(DictionaryDAOImpl.java:305)
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:288)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:154)
   … 35 more
Caused by: org.alfresco.service.namespace.NamespaceException: URI marker.new.model cannot be imported as it is not defined (with prefix marker
   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.<init>(CompiledModel.java:88)
   … 39 more


I hope somebody can help me.
Thanks!
4 REPLIES 4

mitpatoliya
Star Collaborator
Star Collaborator
May the sequence in which you have registered the models are not proper. Not sure give a try by changing the sequence of registering the model.

d_franz
Champ on-the-rise
Champ on-the-rise
How can I change the sequence?
Thanks!

mitpatoliya
Star Collaborator
Star Collaborator
By changing sequence I mean change the order of entries of model in your context file.
You must have one context file where you are registering your content model right?
There you cna change the order.

d_franz
Champ on-the-rise
Champ on-the-rise
Changing the context has not brougt any change. Now I have merkegt bouth files to one. That is no pretty solution but it works.