AnsweredAssumed Answered

URGENT: Unable to create custom content model.

Question asked by amit_wmw@yahoo.com on Mar 30, 2009
Latest reply on Apr 1, 2009 by amit_wmw@yahoo.com
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.dtd'>

<beans>

    <!-- Registration of new models -->   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/Cus.xml</value>
            </list>
        </property>
    </bean>
</beans>'><?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!-- Registration of new models -->   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/Cus.xml</value>
            </list>
        </property>
    </bean>
</beans>


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.

Outcomes