AnsweredAssumed Answered

Error prefix cannot be null or empty in CMIS

Question asked by rutaveejshah on Aug 7, 2013
Latest reply on Aug 12, 2013 by rutaveejshah
Hello Everyone!

I am using alfresco community edition 4.0d. I have connected alfresco using java Open CMIS.When i create a folder using aspect it will guve me error like prefix can not be null.
Below is my code which i am using for creating a folder.

I have tried both Url:-http://localhost:8080/alfresco/cmisatom,http://localhost:8080/alfresco/service/cmis

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.alfresco.cmis.client.AlfrescoFolder;
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Repository;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class Test
{

   
      private Session getSession(String serverUrl, String username, String password)
      {
      SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
      Map<String, String> params = new HashMap<String, String>();
      params.put(SessionParameter.USER, username);
      params.put(SessionParameter.PASSWORD, password);
      params.put(SessionParameter.ATOMPUB_URL, serverUrl);
      params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
      params.put   (SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");         
      List<Repository> repos = sessionFactory.getRepositories(params);
      if (repos.isEmpty()) {
      throw new RuntimeException("Server has no repositories!");
      }
      return repos.get(0).createSession();
      }
public void  createFolder()
      {
         String servalUrl="http://localhost:8080/alfresco/cmisatom";
         String userName="admin";
         String password="admin";
      
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder,P:cm:titled");   
         properties.put(PropertyIds.NAME,"TESTFOLDER2");
         properties.put(PropertyIds.CREATED_BY, "admin");
          properties.put("cm:title", "Title");
         properties.put("cm:description", "Desc");
         Session session=getSession(servalUrl, userName, password);
         AlfrescoFolder root=(AlfrescoFolder) session.getRootFolder();
         System.out.println("The Name:"+root.getId()+root.getName());
         AlfrescoFolder newFolder=(AlfrescoFolder) root.createFolder(properties);
         System.out.println(newFolder.getName());
         
      }


The Error i got is written below.
ERROR:  'prefix cannot be null or empty'
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Cannot access http://localhost:8080/alfresco/cmisatom/76c769fa-85b4-4bee-9621-c55bee0bc89d/children?id=workspace%3A%2F%2FSpacesStore%2F63dd2df1-3731-44be-a971-34d53bd99ece: null
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:203)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invokePOST(HttpUtils.java:70)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:566)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:154)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:769)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:129)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:453)
   at com.tcs.alfresco.sample.Test.createFolder(Test.java:63)
   at com.tcs.alfresco.sample.SampleTest.main(SampleTest.java:8)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.transform.TransformerException: javax.xml.stream.XMLStreamException: prefix cannot be null or empty]
   at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
   at org.apache.chemistry.opencmis.commons.impl.JaxBHelper.marshal(JaxBHelper.java:130)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomEntryWriter.write(AtomEntryWriter.java:146)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl$2.write(ObjectServiceImpl.java:156)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:180)
   … 8 more
Caused by: javax.xml.transform.TransformerException: javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.writeDom(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
   … 14 more
Caused by: javax.xml.transform.TransformerException: javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
   … 29 more
Caused by: javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.attribute(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ContentHandlerAdaptor.startElement(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToSAXHandler.flushPending(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
   … 31 more
Caused by: javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeAttribute(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.output.XMLStreamWriterOutput.attribute(Unknown Source)
   … 43 more
Please if you have any idea reply as early as possible.

Outcomes