cancel
Showing results for 
Search instead for 
Did you mean: 

Error prefix cannot be null or empty in CMIS

rutaveejshah
Champ in-the-making
Champ in-the-making
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%3...: 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.
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
I tested the code , it  run correctly

below is your code

package org.alfresco.sample.webservice;

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());
      System.out.println(newFolder.getId());

   }
   public static void main(String[] args){
      Test t  = new Test();
      t.createFolder();
   }
}


here is the result in console
<strong>
The Name:ce55a850-b1c7-43c7-a600-b5c58a985429公司主页
TESTFOLDER2
</strong>

May be it is a bug of your version 4.0.d (I use 4.2.d)

I have tried using Alfresco community Edition 4.2 d still i got this error.
Tell me which jar file are you used for this.

kaynezhang
World-Class Innovator
World-Class Innovator
alfresco-opencmis-extension-0.3.jar
chemistry-opencmis-***.0.8.0.jar
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.