cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco extension lib

fabernate
Champ in-the-making
Champ in-the-making
Hello all

this method made by me

public AlfrescoDocument upload(File f, String mimeType, AlfrescoFolder folder) throws FileNotFoundException {
      ContentStream contentStream = new ContentStreamImpl(f.getName(), null, mimeType, new FileInputStream(f));
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put(PropertyIds.NAME, contentStream.getFileName());
      properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document, P:cm:titled");
      properties.put("cm:description", "My document");
      
      return (AlfrescoDocument) folder.createDocument(properties, contentStream , VersioningState.NONE);
   }

throws the following exception:


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/1359f0c0-fc71-4b64-85ec-937e440825ce/children?id=workspace%3...: null
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:208)
   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.createDocument(ObjectServiceImpl.java:127)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:716)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:88)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:443)
   at com.lynxspa.util.alfresco.AFRepo.upload(AFRepo.java:116)
   at main.Main.main(Main.java:20)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
javax.xml.transform.TransformerException: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
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$1.write(ObjectServiceImpl.java:129)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:180)
   … 8 more
Caused by: com.sun.istack.internal.SAXException2: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
javax.xml.transform.TransformerException: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
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: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
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: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
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 can you tell me why ?

Thanks
Regards
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
This is most commonly seen when you have a clash in the underlying dependencies. See:
http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/issues/detail?id=2

If you use Maven to manage the dependencies for your client app this should get fixed for you automatically, otherwise, you have to tweak your classpath to make it go away.

In a stubborn attempt to not use Maven for some CMIS examples in the content types tutorial, I spent some time working this out and came up with the following classpath, which I put in my Ant build script:

<path id="classpath.cmis">
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="alfresco-opencmis*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="chemistry-opencmis-client-api*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="chemistry-opencmis-client-bindings*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="chemistry-opencmis-client-impl*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="chemistry-opencmis-commons*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="wstx*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies/commons" includes="commons-logging*.jar" />
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies/commons" includes="commons-codec*.jar" />      
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="jaxws*.jar" /><!–WS binding–>
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="streambuffer*.jar" /><!–WS binding–>
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="stax*.jar" /><!–WS binding–>
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="jaxb*.jar" /><!–WS binding–>
   <fileset dir="${alfresco.sdk.dir}/lib/server/dependencies" includes="mimepull*.jar" /><!–WS binding–>
</path>
I'm coming around to Maven, though, and this is definitely a case where Maven makes your life easier.

Jeff