Juanjo Salvador Juanjo Salvador - 3 months ago 34
Java Question

"Could not import bootstrap model" when trying to package with Alfresco Maven SDK

I'm trying to package an AMP (Alfresco Module Package) with some custom datalists for Alfresco Community. When I launch integration tests, all works fine, but when I try to package it, all I get is an error log with lots of Spring exceptions.

The principal exception is this:

org.alfresco.service.cmr.dictionary.DictionaryException: 07220001 Could not import bootstrap model


And this is my boostrap bean:

<bean id="customdatalist-repo.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/module/${project.artifactId}/model/content-model.xml</value>
</list>
</property>
<!-- LABELS -->
<property name="labels">
<list>
<value>alfresco/module/${project.artifactId}/messages/datalist-model</value>
</list>
</property>
</bean>


I'm following the Datalist Development guide at the Alfresco Docs

UPDATE
Test results.

Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 43.469 sec <<< FAILURE! - in customdatalist.demoamp.test.DemoComponentTest
testChildNodesCount(customdatalist.demoamp.test.DemoComponentTest) Time elapsed: 27.794 sec <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customdatalist-repo.dictionaryBootstrap' defined in class path resource [alfresco/module/customdatalist-repo/context/bootstrap-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 07220001 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220001 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220000 Failed to compile model 'acmedl:datalistModel'
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/model/datalist/1.0 cannot be imported as it is not defined (with prefix dl

testWiring(customdatalist.demoamp.test.DemoComponentTest) Time elapsed: 8.805 sec <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customdatalist-repo.dictionaryBootstrap' defined in class path resource [alfresco/module/customdatalist-repo/context/bootstrap-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 07220003 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220003 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220002 Failed to compile model 'acmedl:datalistModel'
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/model/datalist/1.0 cannot be imported as it is not defined (with prefix dl

testGetCompanyHome(customdatalist.demoamp.test.DemoComponentTest) Time elapsed: 6.431 sec <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customdatalist-repo.dictionaryBootstrap' defined in class path resource [alfresco/module/customdatalist-repo/context/bootstrap-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 07220005 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220005 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220004 Failed to compile model 'acmedl:datalistModel'
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/model/datalist/1.0 cannot be imported as it is not defined (with prefix dl


Stacktrace.

Running customdatalist.demoamp.test.DemoComponentTest
2016-08-22 14:46:08,655 WARN [alfresco.util.RuntimeSystemPropertiesSetter] [main] Could not find alfresco-jmxrmi.password on classpath
2016-08-22 14:46:08,825 INFO [alfresco.repo.admin] [main] Using database URL 'jdbc:h2:/home/juanjo/Documentos/test-sdk/test-repo/customdatalist-project/customdatalist-repo/alf_data_dev/h2_data/alf_dev;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;MVCC=FALSE;LOCK_MODE=0' with user 'alfresco'.
2016-08-22 14:46:09,720 INFO [alfresco.repo.admin] [main] Connected to database H2 version 1.4.190 (2015-10-11)
2016-08-22 14:46:18,074 INFO [domain.schema.SchemaBootstrap] [main] Ignoring script patch (post-Hibernate): patch.db-V4.2-metadata-query-indexes
2016-08-22 14:46:18,074 INFO [domain.schema.SchemaBootstrap] [main] Ignoring script patch (post-Hibernate): patch.db-V5.1-metadata-query-indexes
2016-08-22 14:46:31,391 WARN [context.support.GenericApplicationContext] [main] Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customdatalist-repo.dictionaryBootstrap' defined in class path resource [alfresco/module/customdatalist-repo/context/bootstrap-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 07220001 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:120)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:102)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:246)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:69)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:95)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at com.tradeshift.test.remote.RemoteTestRunner.run(RemoteTestRunner.java:73)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220001 Could not import bootstrap model 'alfresco/module/customdatalist-repo/model/content-model.xml'
at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:173)
at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1640)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
... 42 more
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 07220000 Failed to compile model 'acmedl:datalistModel'
at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:116)
at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:167)
at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModelImpl(DictionaryDAOImpl.java:273)
at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:260)
at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:169)
... 50 more
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/model/datalist/1.0 cannot be imported as it is not defined (with prefix dl
at org.alfresco.repo.dictionary.CompiledModel.createLocalPrefixResolver(CompiledModel.java:214)
at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:138)
at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:96)
... 54 more


And my
content-model.xml


<?xml version="1.0" encoding="UTF-8"?>
<model name="acmedl:datalistModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

<!-- Optional meta-data about the model -->
<description>Seyte DataList test</description>
<author>Juanjo Salvador</author>
<version>1.0</version>

<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<!-- Import Alfresco Data List Model Definitions -->
<import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl" />
</imports>

<!-- Custom namespace for the ACME company Data Lists-->
<namespaces>
<namespace uri="http://www.acme.org/model/datalist/1.0" prefix="acmedl"/>
</namespaces>

<types>
<!--
Data List Item Type for the custom project list
-->
<type name="acmedl:projectListItem">
<title>DataList Seyte</title>
<parent>dl:dataListItem</parent>
<properties>
<property name="acmedl:projectName">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="acmedl:projectDescription">
<type>d:text</type>
</property>
</properties>
</type>
</types>
</model>

Answer

It is not the best way to do this, but looking for a fix, I decided to skip the tests because my package doen't compile by the failed tests.

Solution was:

mvn clean
mvn package -Dmaven.test.skip=true

And install both packages (share and repo) using alfresco-mnt.jar

java -jar bin/alfresco-mnt.jar install <repo package> tomcat/webapps/alfresco.war
java -jar bin/alfresco-mnt.jar install <share package> tomcat/webapps/share.war

Now is done. But remember, THIS IS NOT THE BEST WAY.

Comments