AnsweredAssumed Answered

Issues while using custom content types.

Question asked by on Apr 3, 2009

I have created a very simple custom content model, scModel.xml (in C:\Alfresco\tomcat\shared\classes\alfresco\extension).

<model name="sc:somecomodel" xmlns="">

<!– Optional meta-data about the model –>
<description>Someco Model</description>
<!– Imports are required to allow references to definitions in other models –>
<!– Import Alfresco Dictionary Definitions –>
<import uri="" prefix="d" />
<!– Import Alfresco Content Domain Model Definitions –>
<import uri="" prefix="cm" />
<!– Introduction of new namespaces defined by this model –>
<namespace uri="" prefix="sc" />

<!– Enterprise-wide generic document type –>
<type name="sc:doc">
<title>Someco Document</title>
<type name="sc:marketingDoc">
<title>Someco Marketing Document</title>


And have registered this model in example-model-context.xml as below (in C:\Alfresco\tomcat\shared\classes\alfresco\extension).

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


    <!– Registration of new models –>   

   <bean id="extension1.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">


But I am unable to use it in my java code. While trying to add new node it gives me exception.

Node rootNode = session.getRootNode();
         Node companyHome = rootNode.getNode("app:company_home");
           // create the content node
           Node newnode = companyHome.addNode("sc:"+ document.getName(),"sc:doc");

After executing this code I get below errors:

11:17:09,095 INFO  [service.descriptor.DescriptorService] Alfresco started (Community Network): Current version 2.1.0 (482) schema 64 - Installed version 2.1.0 (482) schema 64
error while creating nodes org.alfresco.service.namespace.NamespaceException: [color=#FF0000]Namespace prefix sc is not mapped to a namespace URI[/color]org.alfresco.service.namespace.NamespaceException: Namespace prefix sc is not mapped to a namespace URI
   at org.alfresco.service.namespace.QName.createQName(
   at org.alfresco.service.namespace.QName.createQName(
   at org.alfresco.jcr.item.JCRPath$SimpleElement.<init>(
   at org.alfresco.jcr.item.JCRPath.<init>(
   at org.alfresco.jcr.item.NodeImpl.addNode(
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(
   at $Proxy85.addNode(Unknown Source)
   at org.hcl.grcmip.workflow.document.vo.impl.Main.main(

Please suggest how should I go about it. I am quite stuck.