AnsweredAssumed Answered

Custom categories on module bootstrap

Question asked by alex.lu on Sep 6, 2011
Hello all,

I'm trying to import custom categories using module bootstrap. I tried following the solution posted in http://forums.alfresco.com/en/viewtopic.php?t=15702 but having no luck. Can anyone give me a hand, please?

bootstrap-context.xml in my amp module

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

   <!– Boostrap model definitions –>
   <bean id="myModule.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
               <value>alfresco/module/myModule/model/myModule.xml</value>
            </list>
        </property>
    </bean>
       
    <!– Bootstrap repository content –>
    <bean id="myModule.spacesBootstrap" class="org.alfresco.repo.module.ImporterModuleComponent" parent="module.baseComponent">
        <property name="moduleId" value="myModule" />
        <property name="name" value="myModule_bootstrapSpaces" />
        <property name="description" value="Initial data requirements" />
        <property name="sinceVersion" value="0.1" />

      <property name="importer" ref="spacesBootstrap"/>
      <!– <property name="executeOnceOnly" value="false" /> –>

        <!– Data properties –>
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/cm:categoryRoot/cm:generalclassifiable</prop>
                    <prop key="location">alfresco/module/myModule/bootstrap/categories.xml</prop>
                </props>
         </list>
        </property>
   </bean>
 
   
</beans>

categories.xml

<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
   xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org"
   xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0"
   xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0"
   xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0"
   xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
   xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
   xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0"
   xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0"
   xmlns:rma="http://www.alfresco.org/model/recordsmanagement/1.0"
   xmlns:dod="http://www.alfresco.org/model/dod5015/1.0" xmlns:custom="custom.model"
   xmlns="">

   <cm:category view:childName="cm:generalclassifiable">
      <cm:name>Custom Categories</cm:name>
      <cm:subcategories>

         <cm:category>
            <cm:name>Document Type</cm:name>
            <cm:subcategories>
               <cm:category>
                  <cm:name>Policy</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Form</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Guidelines</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Procedure</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Factsheet</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Minutes</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Agenda</cm:name>
               </cm:category>
            </cm:subcategories>
         </cm:category>

         <cm:category>
            <cm:name>Department</cm:name>
            <cm:subcategories>
               <cm:category>
                  <cm:name>Academic Registrar</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Student Administration</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Quality Standard and Assessment</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Planning and Management Information</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Course Material</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Corporate Resources</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Executive Group</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Estate Services</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Environmental and Energy</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Bar and Catering</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Residential</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Facilities Management</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Estate Systems Co-ordinator</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Faculty Office at Canterbury</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Faculty Office at Epsom</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Faculty Office at Farnham</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Faculty Office at Maidstone</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Faculty Office at Rochester</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Finance</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Procurement</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Health and Safety</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Human Resources</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Equality and Diversity</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Learning and Development</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>MIS</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Payroll</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>IT Services</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>IT Business Development</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>IT Development</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>IT Service Registry</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Learning and Development</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Learning and Teaching</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Library and Learning Services</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Marketing and Communications</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Research and Enterprise</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Research</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Enterprise</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Gallery</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Student Development Services</cm:name>
               </cm:category>
               <cm:category>
                  <cm:name>Widening Participation</cm:name>
               </cm:category>
            </cm:subcategories>
         </cm:category>
      </cm:subcategories>
   </cm:category>

</view:view>

I deleted everything under alf_data folder and dropped db. Start with a clean db. I'm getting this error.

15:45:51,133 INFO  [org.alfresco.repo.module.ModuleServiceImpl] Found 2 module(s).
15:45:51,231 INFO  [org.alfresco.repo.module.ModuleServiceImpl] Installing module 'myModule' version 1.1.
15:45:52,750 INFO  [org.alfresco.repo.module.ModuleServiceImpl] Found 2 module(s).
15:45:52,815 INFO  [org.alfresco.repo.module.ModuleServiceImpl] Installing module 'myModule' version 1.1.
15:45:52,975 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.alfresco.error.AlfrescoRuntimeException: 08060004 Failed to start modules
   at org.alfresco.repo.module.ModuleComponentHelper$1.doWork(ModuleComponentHelper.java:302)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
   at org.alfresco.repo.module.ModuleComponentHelper.startModules(ModuleComponentHelper.java:196)
   at org.alfresco.repo.module.ModuleServiceImpl.startModules(ModuleServiceImpl.java:137)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy93.startModules(Unknown Source)
   at org.alfresco.repo.module.ModuleStarter$1.execute(ModuleStarter.java:66)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:272)
   at org.alfresco.repo.module.ModuleStarter$2.doWork(ModuleStarter.java:76)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
   at org.alfresco.repo.module.ModuleStarter.onBootstrap(ModuleStarter.java:71)
   at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
   at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
   at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:78)
   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
   at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
   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:3972)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:519)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 08060003 The module component has already been executed: myModule.myModule.spacesBootstrap
   at org.alfresco.error.AlfrescoRuntimeException.create(AlfrescoRuntimeException.java:46)
   at org.alfresco.repo.module.AbstractModuleComponent.execute(AbstractModuleComponent.java:346)
   at org.alfresco.repo.module.ModuleComponentHelper.executeComponent(ModuleComponentHelper.java:645)
   at org.alfresco.repo.module.ModuleComponentHelper.startModule(ModuleComponentHelper.java:564)
   at org.alfresco.repo.module.ModuleComponentHelper.access$400(ModuleComponentHelper.java:57)
   at org.alfresco.repo.module.ModuleComponentHelper$1$1.execute(ModuleComponentHelper.java:239)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:272)
   at org.alfresco.repo.module.ModuleComponentHelper$1.doWork(ModuleComponentHelper.java:260)
   … 54 more



Many thanks in advance

Outcomes