You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by jevon <je...@jevon.org> on 2013/04/16 08:07:52 UTC

Invalid chunk header when replacing Document contents

Hi,

We're having problems with a deployment of OpenCMIS 0.8 interacting with
Alfresco. When using setContentStream() on an existing Document, Alfresco
is reporting an "Invalid chunk header" and the document contents do not
change.

This error doesn't occur when uploading a new document, or on replacing
documents less than 10 KB. Unfortunately I haven't been able to reproduce
it locally but I can reproduce it on a different deployment environment.
Tomcat 7's default Http11 connector does not support disabling chunking. As
far as I can tell, it isn't an issue with permissions, SSL, folder paths,
firewalls, proxies or file content.

As a workaround we're considering having to delete the existing document
before uploading a new one, but this will lose the previous history
associated with the document.

Short of inspecting the data flow with Wireshark/etc, how could we look at
fixing this issue? Could this be an Alfresco, Chemistry, Tomcat or other
issue? Is there any way to convince OpenCMIS to not use a chunked
connection when uploading content?

Thanks for any help.

Jevon

[1] Stacktrace on CMIS client:

org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException:
Internal Server Error
        at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:452)
        at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:595)
        at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.setContentStream(ObjectServiceImpl.java:624)
        at org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentStream(DocumentImpl.java:412)
        at org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentStream(DocumentImpl.java:392)
        at ...


Stacktrace on Alfresco server:

java.lang.RuntimeException: java.io.IOException: Invalid chunk header
        at org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.getInputStream(RepositoryContainer.java:1059)
        at org.alfresco.repo.web.scripts.content.ContentSet.execute(ContentSet.java:175)
        at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:417)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:479)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:517)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:333)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
        at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.IOException: Invalid chunk header
        at org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:133)
        at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:710)
        at org.apache.coyote.Request.doRead(Request.java:427)
        at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304)
        at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:421)
        at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
        at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:162)
        at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:112)
        at org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.getRequestBodyAsFile(RepositoryContainer.java:938)
        at org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.access$600(RepositoryContainer.java:918)
        at org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.getInputStream(RepositoryContainer.java:1055)
        ... 29 more


Code that executes setContentStream():

    public void replaceContents(InputStream stream, long length,
            String contentType) {

        Document doc = (Document) getCmisObject();
        ContentStream contentStream = new ContentStreamImpl(getName(),
BigInteger.valueOf(length), contentType, stream);
        doc.setContentStream(contentStream, true);

    }

RE: Invalid chunk header when replacing Document contents

Posted by Andrew Hind <an...@alfresco.com>.
Hi Jevon

Let us know how you get on.
Please get in touch with Alfresco support - there are not that many of us
read this mailing list!
If you are out of support or using the community product you can still
raise an issue and add all the details.

I would also try using the Opencmis 0.7 client against 4.1.

Regards

Andy


-----Original Message-----
From: jevon [mailto:jevon@jevon.org]
Sent: 22 April 2013 06:32
To: dev@chemistry.apache.org
Subject: Re: Invalid chunk header when replacing Document contents

Hi,

We're using Alfresco Enterprise 4.1.3 (still waiting for Enterprise
4.2.x).
We are using the exact same version both in our development environments
(locally) and in our deployments (remotely).

We're currently using the BindingType.ATOMPUB Binding Type. I've tried
setting the AtomPub URL to both
http://localhost:8080/alfresco/service/cmisand
http://localhost:8080/alfresco/cmisatom, no change. I can share the
connection code if necessary.

Turning on org.alfresco.repo.transaction.RetryingTransactionHelper=debug
displays the following log message before the exception, which makes me
agree it is not related to Alfresco.

2013-04-22 17:13:50,632  DEBUG
[repo.transaction.RetryingTransactionHelper]
[http-8080-1]
Transaction commit failed:
   Thread: http-8080-1
   Txn:
UserTransaction[object=org.alfresco.util.transaction.SpringAwareUserTransa
ction@3b7d7d2e,
status=1]
   Iteration: 0
   Exception follows:
 java.lang.RuntimeException: java.io.IOException: Invalid chunk header
        at ...

The only differences I can identify between the working and broken
containers are:

* Operating system: Locally Windows 7 x64 SP1, remotely Ubuntu 10.04 LTS
* Tomcat version: Locally 7.0.23, remotely 6.0.24
* Java version: Locally 1.7.0_17, remotely 1.6.0_27

I'll deploy Java 6 & Tomcat 6 locally to see if it is a Java/Tomcat issue.
Alternatively I might need to update Tomcat 6 to 6.0.36. Right now our
workaround is deleting the file before uploading.

Thanks for the ideas and feedback!

Jevon


On Tue, Apr 16, 2013 at 9:17 PM, Andrew Hind <an...@alfresco.com>
wrote:

> Hi
>
> Which version of Alfresco are you using?
> (OpenCMIS 0.8 is used in Alfresco 4.2)
>
> When you say you cannot reproduce it locally, do you mean the same
> test passes and chunking works?
> Are you using exactly the same version of Alfresco locally?
>
> It looks like it is not related to Alfresco unless there is some retry
> going on that does not work with chunking.
>
> You could try turning on debug for
> org.alfresco.repo.transaction.RetryingTransactionHelper
> to see if retrying the operation is causing the issue - then it is an
> Alfresco issue.
>
> Are you using web services?
> I have seen something similar before, related to the WS support in the
> container.
> Can you use AtomPub instead?
>
> What is different between the container where it is OK and where it
> breaks?
>
> Andy
>
>
>
> -----Original Message-----
> From: jevon [mailto:jevon@jevon.org]
> Sent: 16 April 2013 07:08
> To: dev@chemistry.apache.org
> Subject: Invalid chunk header when replacing Document contents
>
> Hi,
>
> We're having problems with a deployment of OpenCMIS 0.8 interacting
> with Alfresco. When using setContentStream() on an existing Document,
> Alfresco is reporting an "Invalid chunk header" and the document
> contents do not change.
>
> This error doesn't occur when uploading a new document, or on
> replacing documents less than 10 KB. Unfortunately I haven't been able
> to reproduce it locally but I can reproduce it on a different deployment
environment.
> Tomcat 7's default Http11 connector does not support disabling chunking.
> As far as I can tell, it isn't an issue with permissions, SSL, folder
> paths, firewalls, proxies or file content.
>
> As a workaround we're considering having to delete the existing
> document before uploading a new one, but this will lose the previous
> history associated with the document.
>
> Short of inspecting the data flow with Wireshark/etc, how could we
> look at fixing this issue? Could this be an Alfresco, Chemistry,
> Tomcat or other issue? Is there any way to convince OpenCMIS to not
> use a chunked connection when uploading content?
>
> Thanks for any help.
>
> Jevon
>
> [1] Stacktrace on CMIS client:
>
> org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException:
> Internal Server Error
>         at
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtom
> PubS
> ervice.convertStatusCode(AbstractAtomPubService.java:452)
>         at
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtom
> PubS
> ervice.put(AbstractAtomPubService.java:595)
>         at
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServic
> eImp
> l.setContentStream(ObjectServiceImpl.java:624)
>         at
> org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentSt
> ream
> (DocumentImpl.java:412)
>         at
> org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentSt
> ream
> (DocumentImpl.java:392)
>         at ...
>
>
> Stacktrace on Alfresco server:
>
> java.lang.RuntimeException: java.io.IOException: Invalid chunk header
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.ge
> tInp
> utStream(RepositoryContainer.java:1059)
>         at
> org.alfresco.repo.web.scripts.content.ContentSet.execute(ContentSet.ja
> va:1
> 75)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(Repository
> Cont
> ainer.java:417)
>         at
> org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransactio
> n(Re
> tryingTransactionHelper.java:388)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute
> (Rep
> ositoryContainer.java:479)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute
> As(R
> epositoryContainer.java:517)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(Reposi
> tory
> Container.java:333)
>         at
> org.springframework.extensions.webscripts.AbstractRuntime.executeScrip
> t(Ab
> stractRuntime.java:377)
>         at
> org.springframework.extensions.webscripts.AbstractRuntime.executeScrip
> t(Ab
> stractRuntime.java:209)
>         at
> org.springframework.extensions.webscripts.servlet.WebScriptServlet.ser
> vice
> (WebScriptServlet.java:118)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> cati
> onFilterChain.java:290)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> lter
> Chain.java:206)
>         at
> org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalL
> ocal
> izationFilter.java:61)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> cati
> onFilterChain.java:235)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> lter
> Chain.java:206)
>         at
> net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
>         at
> net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> cati
> onFilterChain.java:235)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> lter
> Chain.java:206)
>         at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.
> java:233)
>         at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.
> java:191)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja
> va:1
> 27)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja
> va:1
> 02)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv
> e.ja
> va:109)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
> :298
> )
>         at
>
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proces
> s(Ht
> tp11Protocol.java:588)
>         at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>         at java.lang.Thread.run(Thread.java:679)
> Caused by: java.io.IOException: Invalid chunk header
>         at
> org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInpu
> tFil
> ter.java:133)
>         at
> org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffe
> r.ja
> va:710)
>         at org.apache.coyote.Request.doRead(Request.java:427)
>         at
> org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.ja
> va:3
> 04)
>         at
> org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:421)
>         at
> org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
>         at
> org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream
> .jav
> a:162)
>         at
> org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:112)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.getR
> eque
> stBodyAsFile(RepositoryContainer.java:938)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.acce
> ss$6
> 00(RepositoryContainer.java:918)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.ge
> tInp
> utStream(RepositoryContainer.java:1055)
>         ... 29 more
>
>
> Code that executes setContentStream():
>
>     public void replaceContents(InputStream stream, long length,
>             String contentType) {
>
>         Document doc = (Document) getCmisObject();
>         ContentStream contentStream = new ContentStreamImpl(getName(),
> BigInteger.valueOf(length), contentType, stream);
>         doc.setContentStream(contentStream, true);
>
>     }
>

Re: Invalid chunk header when replacing Document contents

Posted by jevon <je...@jevon.org>.
Hi,

We're using Alfresco Enterprise 4.1.3 (still waiting for Enterprise 4.2.x).
We are using the exact same version both in our development environments
(locally) and in our deployments (remotely).

We're currently using the BindingType.ATOMPUB Binding Type. I've tried
setting the AtomPub URL to both http://localhost:8080/alfresco/service/cmisand
http://localhost:8080/alfresco/cmisatom, no change. I can share the
connection code if necessary.

Turning on org.alfresco.repo.transaction.RetryingTransactionHelper=debug
displays the following log message before the exception, which makes me
agree it is not related to Alfresco.

2013-04-22 17:13:50,632  DEBUG [repo.transaction.RetryingTransactionHelper]
[http-8080-1]
Transaction commit failed:
   Thread: http-8080-1
   Txn:
UserTransaction[object=org.alfresco.util.transaction.SpringAwareUserTransaction@3b7d7d2e,
status=1]
   Iteration: 0
   Exception follows:
 java.lang.RuntimeException: java.io.IOException: Invalid chunk header
        at ...

The only differences I can identify between the working and broken
containers are:

* Operating system: Locally Windows 7 x64 SP1, remotely Ubuntu 10.04 LTS
* Tomcat version: Locally 7.0.23, remotely 6.0.24
* Java version: Locally 1.7.0_17, remotely 1.6.0_27

I'll deploy Java 6 & Tomcat 6 locally to see if it is a Java/Tomcat issue.
Alternatively I might need to update Tomcat 6 to 6.0.36. Right now our
workaround is deleting the file before uploading.

Thanks for the ideas and feedback!

Jevon


On Tue, Apr 16, 2013 at 9:17 PM, Andrew Hind <an...@alfresco.com> wrote:

> Hi
>
> Which version of Alfresco are you using?
> (OpenCMIS 0.8 is used in Alfresco 4.2)
>
> When you say you cannot reproduce it locally, do you mean the same test
> passes and chunking works?
> Are you using exactly the same version of Alfresco locally?
>
> It looks like it is not related to Alfresco unless there is some retry
> going on that does not work with chunking.
>
> You could try turning on debug for
> org.alfresco.repo.transaction.RetryingTransactionHelper
> to see if retrying the operation is causing the issue - then it is an
> Alfresco issue.
>
> Are you using web services?
> I have seen something similar before, related to the WS support in the
> container.
> Can you use AtomPub instead?
>
> What is different between the container where it is OK and where it
> breaks?
>
> Andy
>
>
>
> -----Original Message-----
> From: jevon [mailto:jevon@jevon.org]
> Sent: 16 April 2013 07:08
> To: dev@chemistry.apache.org
> Subject: Invalid chunk header when replacing Document contents
>
> Hi,
>
> We're having problems with a deployment of OpenCMIS 0.8 interacting with
> Alfresco. When using setContentStream() on an existing Document, Alfresco
> is reporting an "Invalid chunk header" and the document contents do not
> change.
>
> This error doesn't occur when uploading a new document, or on replacing
> documents less than 10 KB. Unfortunately I haven't been able to reproduce
> it locally but I can reproduce it on a different deployment environment.
> Tomcat 7's default Http11 connector does not support disabling chunking.
> As far as I can tell, it isn't an issue with permissions, SSL, folder
> paths, firewalls, proxies or file content.
>
> As a workaround we're considering having to delete the existing document
> before uploading a new one, but this will lose the previous history
> associated with the document.
>
> Short of inspecting the data flow with Wireshark/etc, how could we look at
> fixing this issue? Could this be an Alfresco, Chemistry, Tomcat or other
> issue? Is there any way to convince OpenCMIS to not use a chunked
> connection when uploading content?
>
> Thanks for any help.
>
> Jevon
>
> [1] Stacktrace on CMIS client:
>
> org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException:
> Internal Server Error
>         at
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubS
> ervice.convertStatusCode(AbstractAtomPubService.java:452)
>         at
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubS
> ervice.put(AbstractAtomPubService.java:595)
>         at
> org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImp
> l.setContentStream(ObjectServiceImpl.java:624)
>         at
> org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentStream
> (DocumentImpl.java:412)
>         at
> org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentStream
> (DocumentImpl.java:392)
>         at ...
>
>
> Stacktrace on Alfresco server:
>
> java.lang.RuntimeException: java.io.IOException: Invalid chunk header
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.getInp
> utStream(RepositoryContainer.java:1059)
>         at
> org.alfresco.repo.web.scripts.content.ContentSet.execute(ContentSet.java:1
> 75)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryCont
> ainer.java:417)
>         at
> org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(Re
> tryingTransactionHelper.java:388)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(Rep
> ositoryContainer.java:479)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(R
> epositoryContainer.java:517)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(Repository
> Container.java:333)
>         at
> org.springframework.extensions.webscripts.AbstractRuntime.executeScript(Ab
> stractRuntime.java:377)
>         at
> org.springframework.extensions.webscripts.AbstractRuntime.executeScript(Ab
> stractRuntime.java:209)
>         at
> org.springframework.extensions.webscripts.servlet.WebScriptServlet.service
> (WebScriptServlet.java:118)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati
> onFilterChain.java:290)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter
> Chain.java:206)
>         at
> org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocal
> izationFilter.java:61)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati
> onFilterChain.java:235)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter
> Chain.java:206)
>         at
> net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
>         at
> net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati
> onFilterChain.java:235)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter
> Chain.java:206)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.
> java:233)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.
> java:191)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:1
> 27)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:1
> 02)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.ja
> va:109)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298
> )
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Ht
> tp11Protocol.java:588)
>         at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>         at java.lang.Thread.run(Thread.java:679)
> Caused by: java.io.IOException: Invalid chunk header
>         at
> org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFil
> ter.java:133)
>         at
> org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.ja
> va:710)
>         at org.apache.coyote.Request.doRead(Request.java:427)
>         at
> org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:3
> 04)
>         at
> org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:421)
>         at
> org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
>         at
> org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.jav
> a:162)
>         at
> org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:112)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.getReque
> stBodyAsFile(RepositoryContainer.java:938)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.access$6
> 00(RepositoryContainer.java:918)
>         at
> org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.getInp
> utStream(RepositoryContainer.java:1055)
>         ... 29 more
>
>
> Code that executes setContentStream():
>
>     public void replaceContents(InputStream stream, long length,
>             String contentType) {
>
>         Document doc = (Document) getCmisObject();
>         ContentStream contentStream = new ContentStreamImpl(getName(),
> BigInteger.valueOf(length), contentType, stream);
>         doc.setContentStream(contentStream, true);
>
>     }
>

RE: Invalid chunk header when replacing Document contents

Posted by Andrew Hind <an...@alfresco.com>.
Hi

Which version of Alfresco are you using?
(OpenCMIS 0.8 is used in Alfresco 4.2)

When you say you cannot reproduce it locally, do you mean the same test
passes and chunking works?
Are you using exactly the same version of Alfresco locally?

It looks like it is not related to Alfresco unless there is some retry
going on that does not work with chunking.

You could try turning on debug for
org.alfresco.repo.transaction.RetryingTransactionHelper
to see if retrying the operation is causing the issue - then it is an
Alfresco issue.

Are you using web services?
I have seen something similar before, related to the WS support in the
container.
Can you use AtomPub instead?

What is different between the container where it is OK and where it
breaks?

Andy



-----Original Message-----
From: jevon [mailto:jevon@jevon.org]
Sent: 16 April 2013 07:08
To: dev@chemistry.apache.org
Subject: Invalid chunk header when replacing Document contents

Hi,

We're having problems with a deployment of OpenCMIS 0.8 interacting with
Alfresco. When using setContentStream() on an existing Document, Alfresco
is reporting an "Invalid chunk header" and the document contents do not
change.

This error doesn't occur when uploading a new document, or on replacing
documents less than 10 KB. Unfortunately I haven't been able to reproduce
it locally but I can reproduce it on a different deployment environment.
Tomcat 7's default Http11 connector does not support disabling chunking.
As far as I can tell, it isn't an issue with permissions, SSL, folder
paths, firewalls, proxies or file content.

As a workaround we're considering having to delete the existing document
before uploading a new one, but this will lose the previous history
associated with the document.

Short of inspecting the data flow with Wireshark/etc, how could we look at
fixing this issue? Could this be an Alfresco, Chemistry, Tomcat or other
issue? Is there any way to convince OpenCMIS to not use a chunked
connection when uploading content?

Thanks for any help.

Jevon

[1] Stacktrace on CMIS client:

org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException:
Internal Server Error
        at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubS
ervice.convertStatusCode(AbstractAtomPubService.java:452)
        at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubS
ervice.put(AbstractAtomPubService.java:595)
        at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImp
l.setContentStream(ObjectServiceImpl.java:624)
        at
org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentStream
(DocumentImpl.java:412)
        at
org.apache.chemistry.opencmis.client.runtime.DocumentImpl.setContentStream
(DocumentImpl.java:392)
        at ...


Stacktrace on Alfresco server:

java.lang.RuntimeException: java.io.IOException: Invalid chunk header
        at
org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.getInp
utStream(RepositoryContainer.java:1059)
        at
org.alfresco.repo.web.scripts.content.ContentSet.execute(ContentSet.java:1
75)
        at
org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryCont
ainer.java:417)
        at
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(Re
tryingTransactionHelper.java:388)
        at
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(Rep
ositoryContainer.java:479)
        at
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(R
epositoryContainer.java:517)
        at
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(Repository
Container.java:333)
        at
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(Ab
stractRuntime.java:377)
        at
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(Ab
stractRuntime.java:209)
        at
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service
(WebScriptServlet.java:118)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati
onFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter
Chain.java:206)
        at
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocal
izationFilter.java:61)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati
onFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter
Chain.java:206)
        at
net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
        at
net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati
onFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter
Chain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.
java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.
java:191)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:1
27)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:1
02)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.ja
va:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298
)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Ht
tp11Protocol.java:588)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.IOException: Invalid chunk header
        at
org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFil
ter.java:133)
        at
org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.ja
va:710)
        at org.apache.coyote.Request.doRead(Request.java:427)
        at
org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:3
04)
        at
org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:421)
        at
org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327)
        at
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.jav
a:162)
        at
org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:112)
        at
org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.getReque
stBodyAsFile(RepositoryContainer.java:938)
        at
org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest.access$6
00(RepositoryContainer.java:918)
        at
org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest$1.getInp
utStream(RepositoryContainer.java:1055)
        ... 29 more


Code that executes setContentStream():

    public void replaceContents(InputStream stream, long length,
            String contentType) {

        Document doc = (Document) getCmisObject();
        ContentStream contentStream = new ContentStreamImpl(getName(),
BigInteger.valueOf(length), contentType, stream);
        doc.setContentStream(contentStream, true);

    }