cancel
Showing results for 
Search instead for 
Did you mean: 

Reusing ws:image in custom content model - import error

sam1980
Champ in-the-making
Champ in-the-making
In my custom content model I'd like to create associations to content of type ws:image (As this type is given to all uploaded images in WQS). In order to accomplish this I try to import the model definition by <import uri="http://www.alfresco.org/model/website/1.0" prefix="ws"> and later reference the ws:image in my own content type definition. However this fails during start up with the message "Namespace ws is not mapped to a namespace URI". Imports of other Alfresco content model works as expected.

My own model definition is registered in tomcat/shared/extension. Is not the website-model available at this point in time?

Should I instead maybe create my own image type? If so, how to prevent the WQS machinery to automatically set the type to ws:image on all uploaded images?

Grateful for any insights on the subject.
4 REPLIES 4

bremmington
Champ on-the-rise
Champ on-the-rise
The WQS model should be bootstrapped before any of the context files in <classpath>/alfresco/extension, so I don't think that's the problem. Post your Spring context file and model definition here, and say precisely where these files are located in your system, and I'll see if anything looks wrong.

sam1980
Champ in-the-making
Champ in-the-making
On a clean Alfresco install i "enabled" \tomcat\shared\classes\alfresco\extension\custom-model-context.xml and \tomcat\shared\classes\alfresco\extension\customModel.xml

I then edited customModel.xml and extended the import with http://www.alfresco.org/model/website/1.0 in this way:

   <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 Website Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/website/1.0" prefix="ws"/>
   </imports

When I restart the following error can be read from the logs (relevant lines in bold):

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\AlfrescoEditorial\tomcat\shared\classes\alfresco\extension\custom-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 09010001 Could not import bootstrap model alfresco/extension/customModel.xml
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
   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:4135)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
   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:445)
   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.service.cmr.dictionary.DictionaryException: 09010001 Could not import bootstrap model alfresco/extension/customModel.xml
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:158)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:105)
   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.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1529)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1468)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
   … 37 more
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 09010000 Failed to compile model custom:customModel
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:106)
   at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:128)
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:270)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:154)
   … 45 more
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/model/website/1.0 cannot be imported as it is not defined (with prefix ws
   at org.alfresco.repo.dictionary.CompiledModel.createLocalPrefixResolver(CompiledModel.java:203)
   at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:128)
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:88)
   … 48 more

bremmington
Champ on-the-rise
Champ on-the-rise
It's possible that Spring is firing initialisation of your model before the initialisation of the WQS model. Please would you try adding a dependency between your custom dictionary bootstrap and the WQS dictionary bootstrap, so your custom bootstrap bean looks something like:

<bean id="myDictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="wcmquickstartmodule_dictionaryBootstrap">
   ….
</bean>

sam1980
Champ in-the-making
Champ in-the-making
Makes sense… and works like a charm. Thanks