Florian
Florian

Reputation: 33

Alfresco Issue: URI cannot be imported as it is not defined (with prefix

I'm migrating an application based on Alfresco 3.2r13 from linux/IntelliJ/Ant toward Windows/Eclipse.

Later the aimed will be to add Maven to the Eclipse project, but for now, I just want it to work.

Currently I'm facing the following issue:

I add the contentTypesModel.xml to the project, here are the first lines:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Optional meta-data about the model -->
<description>Example custom Model</description>
<author></author>
<version>1.0</version>

<!-- Imports are required to allow references to definitions in other models -->
<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 uri="http://www.alfresco.org/grimoire/model/ma0189cstr/1.0" prefix="ma0189cstr"/>
    <import uri="http://www.alfresco.org/grimoire/model/ma43110cstr/1.0" prefix="ma43110cstr" />
    <import uri="http://www.alfresco.org/grimoire/model/baremesSys/1.0"
            prefix="baremesSys"/>
    <import uri="http://www.alfresco.org/grimoire/model/baremes/1.0"
            prefix="baremes"/>
    <import
            uri="http://www.alfresco.org/grimoire/model/workflow/baremes/perimetres/1.0"
            prefix="perimetres"/>
</imports>

<!-- Introduction of new namespaces defined by this model -->
<!-- NOTE: The following namespace my.new.model should be changed to reflect
    your own namespace -->
<namespaces>
    <namespace uri="http://www.alfresco.org/grimoire/model/contenttypes/1.0"
               prefix="GPCT"/>
</namespaces>

When trying to Run the Tomcat Server, I got the following error trace:

> 23 déc. 2015 16:28:44,047  ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [D:\TomcatGrimoire\webapps\GrimoireMk0\WEB-INF\classes\alfresco\extension\gp-models-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 11230001 Could not import bootstrap model alfresco/extension/contentTypesModel.xml
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11230001 Could not import bootstrap model alfresco/extension/contentTypesModel.xml
    at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:150)
    at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:108)
    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:606)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:69)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    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:606)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11230000 Failed to compile model GPCT:gpcontenttypeswfmodel
    at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:112)
    at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:134)
    at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:273)
    at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:146)
    ... 34 more
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/grimoire/model/ma0189cstr/1.0 cannot be imported as it is not defined (with prefix ma0189cstr
    at org.alfresco.repo.dictionary.CompiledModel.createLocalPrefixResolver(CompiledModel.java:209)
    at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:134)
    at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:94)
    ... 37 more

The file wfMA0189Constraints.xml contains the following definition:

<!-- Optional meta-data about the model -->
<description>MA0189 Constraints Workflow Model</description>
<author>FSE</author>
<version>1.0</version>

<!-- Imports are required to allow references to definitions in other models -->
<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"/>

</imports>

<!-- Introduction of new namespaces defined by this model -->
<namespaces>
    <namespace uri="http://www.alfresco.org/grimoire/model/ma0189cstr/1.0" prefix="ma0189cstr"/>
</namespaces>

As far as I understand the error, the content of the file is not acknowledged by the tomcat server. The thing is that after a check the tomcat build does contain the file.

So I'm stuck on this error. Any hlep will be welcome.

Thanks in advance and happy holidays.

Upvotes: 1

Views: 2042

Answers (4)

Marco Altieri
Marco Altieri

Reputation: 3818

If you are sure that no context files are loading the model, it is possible that the model is manually uploaded in "Data Dictionary/model". This folder can be used to add new content models dynamically on a running instance of Alfresco.

Is it possible that someone wanted to make these constraints modifiable by end users?

Do you have an instance where the deployment worked? If yes, could you check if the model is deployed in that folder?

Upvotes: 0

mitpatoliya
mitpatoliya

Reputation: 2037

It seems like you are missing entry of "wfMA0189Constraints.xml" model file in your context file. That is the reason Alfresco is not able to pickup that model and hence it shows prefix as unidentified prefix.

Based on your logs I see you are using "gp-models-context.xml" as your context file. Are you able to see entry of this model file (wfMA0189Constraints.xml) there?

Upvotes: 0

Nick Nagels
Nick Nagels

Reputation: 131

The issue might be caused by the order in which the content models are loaded. This might explain the difference between IntelliJ and Eclipse.

If you want to be sure about the order you can use depends-on as an attribute in the bean initialization.

If the models are in different modules you can also use module dependencies. See example: http://docs.alfresco.com/4.2/concepts/dev-extensions-modules-module-properties.html

Upvotes: 1

Marco Altieri
Marco Altieri

Reputation: 3818

There should be a spring context file deployed probably in the extension path. The name of the file usually ends with "-context.xml". Look for a context file that contains the name of the content model file: you should see the definition of a bean with parent="dictionaryModelBootstrap".

If you cannot find this context file, try to find it in your source code and see how it was packaged by intellij/ant

Please find more details at: http://docs.alfresco.com/5.1/tasks/dev-extensions-content-models-tutorials-deploy-model.html

Upvotes: 1

Related Questions