BlackLabs / play-morphia

Provide mongodb access service to play.db.Model via Morphia
Apache License 2.0
130 stars 49 forks source link

Blob storage to file system - Malformed key? #124

Open shoon opened 10 years ago

shoon commented 10 years ago

Version: Play-morphia 1.5.0a

I get a warning every time I save a blob in my model:

10:19:51,968 WARN  ~ error load blob by key[MyStoredBlob_53971403a31057eb1c0aefd6]
java.io.IOException: File is a directory or not readable
        at org.osgl.storage.impl.SObject.of(SObject.java:156)
        at org.osgl.storage.impl.SObject.valueOf(SObject.java:166)
        at org.osgl.storage.impl.FileSystemService.get(FileSystemService.java:84)
        at play.modules.morphia.BlobStorageService.get(BlobStorageService.java:172)
        at play.modules.morphia.Blob.load(Blob.java:179)
        at models.MyBlob.loadBlobs(MyBlob.java)
        at play.modules.morphia.Model._h_Loaded(Model.java:950)
        at play.modules.morphia.MorphiaPlugin$1.postLoad(MorphiaPlugin.java:588)
        at org.mongodb.morphia.mapping.MappedClass.callGlobalInterceptors(MappedClass.java:458)
        at org.mongodb.morphia.mapping.MappedClass.callLifecycleMethods(MappedClass.java:421)
        at org.mongodb.morphia.mapping.Mapper.fromDb(Mapper.java:597)
        at org.mongodb.morphia.mapping.Mapper.fromDBObject(Mapper.java:296)
        at org.mongodb.morphia.query.MorphiaIterator.convertItem(MorphiaIterator.java:78)
        at org.mongodb.morphia.query.MorphiaIterator.processItem(MorphiaIterator.java:65)
        at org.mongodb.morphia.query.MorphiaIterator.next(MorphiaIterator.java:60)
        at org.mongodb.morphia.query.QueryImpl.get(QueryImpl.java:415)
        at play.modules.morphia.Model$MorphiaQuery.get(Model.java:1580)
        at play.modules.morphia.Model.findById(Model.java:747)
        at models.MyBlob.findById(MyBlob.java)
        at controllers.StorageApi.saveMyBlob(StorageApi.java:158)
        at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:557)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:508)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
        at Invocation.HTTP Request(Play!)

The file is committed to the file system just fine and I can retrieve it.

The file is in a time stamped directory and has the file extension. I suspect the key fed to the osgl reader is missing the directory or the file extension.

find . | grep 53971403a31057eb1c0aefd6

./2014/06/10/MyStoredBlob_53971403a31057eb1c0aefd6.zip
./2014/06/10/MyStoredBlob_53971403a31057eb1c0aefd6.zip.attr

My configuration:

morphia.id.type=ObjectId
morphia.logger=false

morphia.db.seeds=192.168.1.10:27017
morphia.db.name=xx
morphia.db.username=xx
morphia.db.password=xx

morphia.storage=fs
morphia.storage.default=fs

morphia.storage.migrateData=false

morphia.storage.fs.serviceImpl=org.osgl.storage.impl.FileSystemService

morphia.storage.fs.home.dir=/test/db/morphia_upload_files
morphia.storage.fs.home.url=/public/uploads
shoon commented 10 years ago

Pretty sure this is related to #117

greenlaw110 commented 10 years ago

117 closed already, so you mean the issue is still there? Or the fix to #117 caused this issue? Sorry I don't have too much time on play-morphia for the moment

shoon commented 10 years ago

I think the issue in 117 is resolved but there's a section of code that prints out the warning but continues on:

BlobStorageService.java, Line 171

shoon commented 9 years ago

I started a new project recently and wanted to note here how I muted the warning in log4j using StringMatchFilter. Some day will submit a patch :)

log4j.appender.Rolling.filter.1=org.apache.log4j.varia.StringMatchFilter
log4j.appender.Rolling.filter.1.StringToMatch=error load blob by key
log4j.appender.Rolling.filter.1.AcceptOnMatch=false