cancel
Showing results for 
Search instead for 
Did you mean: 

URGENT: Unable to create custom content model.

amit_wmw
Champ in-the-making
Champ in-the-making
Hello

I have created a new custom content as suggested in http://wiki.alfresco.com/wiki/Data_Dictionary_Guide

Step-1] Code is as below and have placed it in C:\Alfresco\tomcat\shared\classes\alfresco\extension.

<model name="cus:custommodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Alfresco Content Domain Model</description>
   <author>Amit</author>
   <published>2009-03-30</published>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
     <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>

   </imports>
  
   <namespaces>
      <namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cus"/>
   </namespaces>

   <constraints>
      <constraint name="cus:filename" type="REGEX">
         <parameter name="expression"><value><![CDATA[(.*[\"\*\\\>\<\?\/\:\|]+.*)|(.*[\.]?.*[\.]+$)|(.*[ ]+$)]]></value></parameter>
         <parameter name="requiresMatch"><value>false</value></parameter>
      </constraint>
      <constraint name="cus:userNameConstraint" type="org.alfresco.repo.dictionary.constraint.UserNameConstraint" />
   </constraints>
   <types>
  
      <type name="cus:cusobject">
         <title>Object</title>
         <parent>sys:base</parent>
         <properties>
            <property name="cus:name">
               <title>Name</title>
               <type>d:text</type>
               <mandatory enforced="true">true</mandatory>
               <constraints>
                  <constraint ref="cus:filename" />
               </constraints>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>cus:auditable</aspect>
         </mandatory-aspects>
      </type>
     
      <type name="cus:folder">
         <title>Folder</title>
         <parent>cus:cusobject</parent>
         <archive>true</archive>
         <associations>
            <child-association name="cus:contains">
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>sys:base</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
               <duplicate>false</duplicate>
            </child-association>
         </associations>
      </type>
     
      <type name="cus:content">
         <title>Content</title>
         <parent>cus:cusobject</parent>
         <archive>true</archive>
         <properties>
            <property name="cus:content">
               <type>d:content</type>
               <mandatory>false</mandatory>
               <!— Index content in the background –>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
               </index>
            </property>
         </properties>
      </type>
     
      <type name="cus:dictionaryModel">
         <title>Dictionary Model</title>
         <parent>cus:content</parent>
         <properties>
            <property name="cus:modelName">
               <title>Model name</title>
               <type>d:qname</type>
               <protected>true</protected>
            </property>
            <property name="cus:modelDescription">
               <title>Description</title>
               <type>d:text</type>
               <protected>true</protected>
            </property>
            <property name="cus:modelAuthor">
               <title>Author</title>
               <type>d:text</type>
               <protected>true</protected>
            </property>
            <property name="cus:modelPublishedDate">
               <title>Published Date</title>
               <type>d:date</type>
               <protected>true</protected>
            </property>
   <aspects>
  
      <aspect name="cm:titled">
         <title>Titled</title>
         <properties>
            <property name="cm:title">
               <title>Title</title>
               <type>d:mltext</type>
            </property>
            <property name="cm:description">
               <title>Description</title>
               <type>d:mltext</type>
            </property>
         </properties>
      </aspect>
  
      <aspect name="cm:auditable">
         <title>Auditable</title>
         <properties>
            <property name="cm:created">
               <title>Created</title>
               <type>d:datetime</type>
               <protected>true</protected>
               <mandatory enforced="true">true</mandatory>
            </property>
            <property name="cm:creator">
               <title>Creator</title>
               <type>d:text</type>
               <protected>true</protected>
               <mandatory enforced="true">true</mandatory>
            </property>
            <property name="cm:modified">
               <title>Modified</title>
               <type>d:datetime</type>
               <protected>true</protected>
               <mandatory enforced="true">true</mandatory>
            </property>
            <property name="cm:modifier">
               <title>Modifier</title>
               <type>d:text</type>
               <protected>true</protected>
               <mandatory enforced="true">true</mandatory>
            </property>
            <property name="cm:accessed">
               <title>Accessed</title>
               <type>d:datetime</type>
               <protected>true</protected>
            </property>
         </properties>
      </aspect>

</model>

Step-2] Then I registered it in example-model-context.xml file as below.


<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dt...


























Step-3] But while starting server I am getting below errors.

Mar 30, 2009 8:06:35 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive alfresco.war
20:07:15,371 WARN  [remoting.rmi.RmiRegistryFactoryBean] Could not detect RMI regist
ry - creating new one
20:07:16,043 ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with na
me 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classe
s\alfresco\extension\example-model-context.xml]: Invocation of init method failed; n
ested exception is org.alfresco.service.cmr.dictionary.DictionaryException: Could no
t import bootstrap model alfresco/extension/Cus.xml
Caused by:
org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap
model alfresco/extension/Cus.xml
        at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBoot
strap.java:111)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
mpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1160)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1122)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.createBean(AbstractAutowireCapableBeanFactory.java:429)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject
(AbstractBeanFactory.java:250)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.ge
tSingleton(DefaultSingletonBeanRegistry.java:141)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs
tractBeanFactory.java:247)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs
tractBeanFactory.java:161)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preI
nstantiateSingletons(DefaultListableBeanFactory.java:273)
        at org.springframework.context.support.AbstractApplicationContext.refresh(Ab
stractApplicationContext.java:346)
        at org.springframework.web.context.support.AbstractRefreshableWebApplication
Context.refresh(AbstractRefreshableWebApplicationContext.java:156)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext
(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(C
ontextLoader.java:184)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(
ContextLoaderListener.java:49)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.ja
va:3764)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)

        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.jav
a:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311
)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSup
port.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
mpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: Failed to parse
model
        at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:99)
        at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBoot
strap.java:106)
        … 42 more
Caused by: org.jibx.runtime.JiBXException: Expected end tag, found start tag "{http:
//www.alfresco.org/model/dictionary/1.0}aspect" (line 110, col 32)
        at org.jibx.runtime.impl.UnmarshallingContext.toEnd(UnmarshallingContext.jav
a:548)
        at org.jibx.runtime.impl.UnmarshallingContext.parsePastEndTag(UnmarshallingC
ontext.java:805)
        at org.alfresco.repo.dictionary.M2Class.JiBX_root_projects_repository_source
_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_0(M2Class.java)
        at org.alfresco.repo.dictionary.M2Type.JiBX_root_projects_repository_source_
java_org_alfresco_repo_dictionary_m2binding_unmarshal_2_0(M2Type.java)
        at org.alfresco.repo.dictionary.JiBX_root_projects_repository_source_java_or
g_alfresco_repo_dictionary_m2bindingM2Type_access.unmarshal()
        at org.alfresco.repo.dictionary.JiBX_MungeAdapter.JiBX_root_projects_reposit
ory_source_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_4()
        at org.alfresco.repo.dictionary.M2Model.JiBX_root_projects_repository_source
_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_0(M2Model.java)
        at org.alfresco.repo.dictionary.JiBX_root_projects_repository_source_java_or
g_alfresco_repo_dictionary_m2bindingM2Model_access.unmarshal()
        at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(Unmarshalling
Context.java:2515)
        at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(Unmarshallin
gContext.java:2675)
        at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:94)
        … 43 more
20:07:16,355 ERROR [[Catalina].[localhost].[/alfresco]] Exception sending context in
itialized event to listener instance of class org.springframework.web.context.Contex
tLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with na
me 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classe
s\alfresco\extension\example-model-context.xml]: Invocation of init method failed; n
ested exception is org.alfresco.service.cmr.dictionary.DictionaryException: Could no
t import bootstrap model alfresco/extension/Cus.xml
Caused by:
org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap
model alfresco/extension/Cus.xml
        at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBoot
strap.java:111)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
mpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1160)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1122)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.createBean(AbstractAutowireCapableBeanFactory.java:429)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject
(AbstractBeanFactory.java:250)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.ge
tSingleton(DefaultSingletonBeanRegistry.java:141)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs
tractBeanFactory.java:247)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs
tractBeanFactory.java:161)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preI
nstantiateSingletons(DefaultListableBeanFactory.java:273)
        at org.springframework.context.support.AbstractApplicationContext.refresh(Ab
stractApplicationContext.java:346)
        at org.springframework.web.context.support.AbstractRefreshableWebApplication
Context.refresh(AbstractRefreshableWebApplicationContext.java:156)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext
(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(C
ontextLoader.java:184)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(
ContextLoaderListener.java:49)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.ja
va:3764)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)

        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.jav
a:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311
)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSup
port.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
mpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: Failed to parse
model
        at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:99)
        at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBoot
strap.java:106)
        … 42 more
Caused by: org.jibx.runtime.JiBXException: Expected end tag, found start tag "{http:
//www.alfresco.org/model/dictionary/1.0}aspect" (line 110, col 32)
        at org.jibx.runtime.impl.UnmarshallingContext.toEnd(UnmarshallingContext.jav
a:548)
        at org.jibx.runtime.impl.UnmarshallingContext.parsePastEndTag(UnmarshallingC
ontext.java:805)
        at org.alfresco.repo.dictionary.M2Class.JiBX_root_projects_repository_source
_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_0(M2Class.java)
        at org.alfresco.repo.dictionary.M2Type.JiBX_root_projects_repository_source_
java_org_alfresco_repo_dictionary_m2binding_unmarshal_2_0(M2Type.java)
        at org.alfresco.repo.dictionary.JiBX_root_projects_repository_source_java_or
g_alfresco_repo_dictionary_m2bindingM2Type_access.unmarshal()
        at org.alfresco.repo.dictionary.JiBX_MungeAdapter.JiBX_root_projects_reposit
ory_source_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_4()
        at org.alfresco.repo.dictionary.M2Model.JiBX_root_projects_repository_source
_java_org_alfresco_repo_dictionary_m2binding_unmarshal_1_0(M2Model.java)
        at org.alfresco.repo.dictionary.JiBX_root_projects_repository_source_java_or
g_alfresco_repo_dictionary_m2bindingM2Model_access.unmarshal()
        at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(Unmarshalling
Context.java:2515)
        at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(Unmarshallin
gContext.java:2675)
        at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:94)
        … 43 more

I am absolutely clue less about the issue. Please suggest how to get this configured correctly.

Many thanks
Amit.
6 REPLIES 6

amit_wmw
Champ in-the-making
Champ in-the-making
Can anybody please help me on resolving the above basic configuration issue? Is there any correction I need to do in my above mentioned .xml files or do I need to configure few more things to run this correctly. Well I can see issue only at configuration level (i.e either something went wrong in example-model-context.xml file or I have to do few more configuration in some other place)

Please please suggest.

Thanks
Amit.

mikeh
Star Contributor
Star Contributor
The XML isn't well formed (as the exception points out).

Mike

mrogers
Star Contributor
Star Contributor
In particular the closing tags for "types" and "aspects" are missing.

amit_wmw
Champ in-the-making
Champ in-the-making
Dear Mike & Rogers,

Thanks a lot for you kind help! Now I corrected the XML file and made it well formed, so server started properly without any issues. But I still stuck up while executing my java programs if I use my custom model tag "cus:" instead of "cm:" while creating nodes. Program terminates with below error message.


org.alfresco.service.namespace.NamespaceException: Namespace prefix cus is not mapped to a namespace URI error while creating nodes org.alfresco.service.namespace.NamespaceException: Namespace prefix cus is not mapped to a namespace URI

   at org.alfresco.service.namespace.QName.createQName(QName.java:103)
   at org.alfresco.service.namespace.QName.createQName(QName.java:125)
   at org.alfresco.jcr.item.JCRPath$SimpleElement.<init>(JCRPath.java:118)
   at org.alfresco.jcr.item.JCRPath.<init>(JCRPath.java:70)
   at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:152)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138)
   at $Proxy85.addNode(Unknown Source)
   at org.hcl.grcmip.workflow.document.jcr.impl.JCRTemplateImpl.save(JCRTemplateImpl.java:63)
   at org.hcl.grcmip.workflow.document.vo.impl.Main.main(Main.java:30)

And I suppose its coming because of the below lines which I put while making my custom content model:

<namespaces>
     <namespace uri="http://www.alfres.orz/model/content/1.0" prefix="cus"/>
   </namespaces>
.

Will you please suggest if this also should be configured some where else or do I need to specify this in a diffrent way?

Thank again.

Amit.

amit_wmw
Champ in-the-making
Champ in-the-making
can anybody please suggest if namesapce <"namespace uri="http://www.alfresco.org/model/using/1.0" prefix="cus"/"> we give while building our custom model has to be configured somewhere else also? Like in some Metadata extractor or Qname or in some other place or property file? Because while I execute my java program the exception  suggest the same "Namespace prefix cus is not mapped to a namespace URI"!!!

Thanks
Amit.

amit_wmw
Champ in-the-making
Champ in-the-making
Hello,

I can see that Namespace prefix and namespace URI are configured in "NamespaceService" interface in SDK. But if I am not using alfresco SDK but only alfresco server and my own custom jsr code how and where to make this configuration(in alfresco server)? Or is there some problem something somewhere else? Please suggest, I am a bit lost here.

Thanks
Amit.