I'm trying to run an open-source tool that uses sbt on localhost (9000). However, when I try to upload a file (.arrf) to the tool, which is the first thing required by the tool, I get a FileNotFound error as in the following image.
I have no experience with Scala and have limited experience with JS but as far as I understand there is an issue when uploading the file to the server. I tried with files of different sizes and with files used by the original author. I looked into the code and file upload is handled by a FileUploadService.scala class which is as the following,
class FileUploadService(serviceSavePath: String) {
val basePath = if (serviceSavePath.endsWith("/")) {
serviceSavePath
} else { serviceSavePath "/" }
val uploadedParts: ConcurrentMap[String, Set[FileUploadInfo]] = new ConcurrentHashMap(8, 0.9f, 1)
def fileNameFor(fileInfo: FileUploadInfo) = {
s"${basePath}${fileInfo.resumableIdentifier}-${fileInfo.resumableFilename}"
}
def isLast(fileInfo: FileUploadInfo): Boolean = {
(fileInfo.resumableTotalSize - (fileInfo.resumableChunkSize * fileInfo.resumableChunkNumber)) < fileInfo.resumableChunkSize
}
def savePartialFile(filePart: Array[Byte], fileInfo: FileUploadInfo) {
if (filePart.length != fileInfo.resumableChunkSize & !isLast(fileInfo)) {
println("error uploading part")
return
}
val partialFile = new RandomAccessFile(fileNameFor(fileInfo), "rw")
val offset = (fileInfo.resumableChunkNumber - 1) * fileInfo.resumableChunkSize
try {
partialFile.seek(offset)
partialFile.write(filePart, 0, filePart.length)
} finally {
partialFile.close()
}
val key = fileNameFor(fileInfo)
if (uploadedParts.containsKey(key)) {
val partsUploaded = uploadedParts.get(key)
uploadedParts.put(key, partsUploaded fileInfo)
} else {
uploadedParts.put(key, Set(fileInfo))
}
}
As far as I understand from the error, the error occurs in the savePartialFile function where it tries to create a new Random Access File. Here are the details of the last GET request before the error occurs. I also added the error log below. I added quite a lot of outputs and details because I'm very inexperienced in scala and web dev, yet I hope everything is clear.
Cheers!
2022-01-05 13:56:15,972 [ERROR] from application in application-akka.actor.default-dispatcher-86 -
! @7m99nng77 - Internal server error, for (POST) [/upload?resumableChunkNumber=3&resumableChunkSize=1048576&resumableCurrentChunkSize=1048576&resumableTotalSize=17296294&resumableType=&resumableIdentifier=17296294-mixedDriftarff&resumableFilename=mixedDrift.arff&resumableRelativePath=mixedDrift.arff&resumableTotalChunks=16] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[FileNotFoundException: .\tmp\arff\17296294-mixedDriftarff-mixedDrift.arff (The system cannot find the path specified)]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:255)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:182)
at play.core.server.AkkaHttpServer$$anonfun$$nestedInanonfun$executeHandler$1$1.applyOrElse(AkkaHttpServer.scala:230)
at play.core.server.AkkaHttpServer$$anonfun$$nestedInanonfun$executeHandler$1$1.applyOrElse(AkkaHttpServer.scala:229)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:412)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at play.api.libs.streams.Execution$trampoline$.executeScheduled(Execution.scala:109)
at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:71)
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:68)
at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1(Promise.scala:284)
at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1$adapted(Promise.scala:284)
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:284)
at scala.concurrent.Promise.complete(Promise.scala:49)
at scala.concurrent.Promise.complete$(Promise.scala:48)
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:183)
at scala.concurrent.Promise.failure(Promise.scala:100)
at scala.concurrent.Promise.failure$(Promise.scala:100)
at scala.concurrent.impl.Promise$DefaultPromise.failure(Promise.scala:183)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:38)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:43)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.io.FileNotFoundException: .\tmp\arff\17296294-mixedDriftarff-mixedDrift.arff (The system cannot find the path specified)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:124)
at services.FileUploadService.savePartialFile(FileUploadService.scala:30)
at controllers.OverviewController.$anonfun$upload$3(OverviewController.scala:161)
at play.api.data.Form.fold(Form.scala:144)
at controllers.OverviewController.$anonfun$upload$1(OverviewController.scala:156)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at play.api.mvc.ActionBuilderImpl.invokeBlock(Action.scala:482)
at play.api.mvc.ActionBuilderImpl.invokeBlock(Action.scala:480)
at play.api.mvc.ActionBuilder$$anon$9.invokeBlock(Action.scala:331)
at play.api.mvc.ActionBuilder$$anon$9.invokeBlock(Action.scala:326)
at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:419)
at play.api.mvc.Action.$anonfun$apply$2(Action.scala:96)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:302)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
... 12 common frames omitted
CodePudding user response:
Apparently, the author of the code is not creating folders programmatically in the code. So creating two empty directories as "tmp/arrf" in the base directory of the sbt project worked.


