You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Sven Hohlfeld <me...@sven-hohlfeld.de> on 2010/08/18 00:53:10 UTC
Problems with document update followed by attachment creation
Hello,
I am using jcouchdb in a groovy project. I stumbled into serious problems when I
update a document and afterwards create some attachements for this document.
I always get a "java.net.SocketException" (sometimes broken pipe, sometimes connection reset).
This is the relevant groovy code:
document.suggestedTags = suggestedTagsWithFrequence
database.updateDocument(document)
//refresh
final Map document4ImgExtraction = database.getDocument(Map.class, docId)
log.debug 'Beginning image extraction...'
List extractedImages = this.imageExtraction(file)
this.addThumbsToDocument(database, document4ImgExtraction, extractedImages)
which calls this method of course:
protected void addThumbsToDocument(final Database couchdb, final Map currentDocument, final List extractedImageFiles) {
String revision = currentDocument._rev
extractedImageFiles.each {final File pngFile ->
revision = couchdb.createAttachment(currentDocument._id, revision, pngFile.name, 'image/png', pngFile.readBytes()))
log.info "Prepared attachement for document: ${currentDocument._id} with filename: ${pngFile.name} and revision: ${revision}"
}
}
and produces the following stacktrace (part):
Caused by: org.jcouchdb.exception.CouchDBException: java.net.SocketException: Connection reset
at org.jcouchdb.util.ExceptionWrapper.wrap(ExceptionWrapper.java:44)
at org.jcouchdb.db.ServerImpl.executePut(ServerImpl.java:144)
at org.jcouchdb.db.ServerImpl.put(ServerImpl.java:303)
at org.jcouchdb.db.Database.createAttachment(Database.java:963)
at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(Poj
oMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
//this is the line where couchdb.createAttachment(currentDocument._id...) is called
at com.doctape.processing.InboundUploadsService$_addThumbsToDocument_closure1.doCall(InboundUploadsService
.groovy:86)
at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at groovy.lang.Closure.call(Closure.java:276)
at groovy.lang.Closure.call(Closure.java:289)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1184)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1160)
at org.codehaus.groovy.runtime.dgm$111.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoM
etaMethodSite.java:270)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
//This is the 'looping' each closure (extractedImageFiles.each{...
at com.doctape.processing.InboundUploadsService.addThumbsToDocument(InboundUploadsService.groovy:84)
The problem occurs only in the combination of the document update followed by the attachment creation. If I comment one thing out (document update or createAttachment calls)
it works.
Any ideas are highly appreciated :-)
Cheers, Sven