cloudinary/cloudinary_scala

Can't upload message

Hajto opened this issue · 2 comments

Hajto commented

I tried uploading image using "com.cloudinary" %% "cloudinary-core-scala" % "0.9.8-SNAPSHOT" and app crashed with stacktrace:


java.lang.NoClassDefFoundError: Could not initialize class com.cloudinary.HttpClient$
    at com.cloudinary.Uploader.callApi(Uploader.scala:65)
    at com.cloudinary.Uploader.upload(Uploader.scala:87)
    at com.smartoffice.services.ImageService$$anonfun$uploadImage$1.apply(ImageService.scala:31)
    at com.smartoffice.services.ImageService$$anonfun$uploadImage$1.apply(ImageService.scala:30)
    at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
    at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
    at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Code:


  val path = s"temp/$folder/${imageRequest.metadata.fileName}"
    val file = new File(path)
    file.getParentFile.mkdirs()

    processFile(path, imageRequest.byteSource).flatMap { _ =>
      cloudinary.uploader().upload(path).map { thing =>
        ImageResponse(thing.url)
      }
    }

The file exists and is readable.

@Hajto How are you running this code? Is it run from a jar or war or something? If so could it be a problem in the way you pack it.
See https://oss.sonatype.org/content/repositories/snapshots/com/cloudinary/cloudinary-core-scala_2.11/0.9.8-SNAPSHOT/cloudinary-core-scala_2.11-0.9.8-SNAPSHOT.jar
The class is there.
Also, you might want to change your version to the latest 0.9.9-SNAPSHOT

Hajto commented

@itaibenari Sry for not responding for such long time. For some reason it works now....