MongoDBReact性流运行时依赖性错误,Alpakka Mongo连接器ClassNotFoundException

hgc7kmma  于 2022-11-23  发布在  Go
关注(0)|答案(1)|浏览(107)

我正在尝试将Alpakka Mongo Connector集成到一个严重依赖Akka libraries for stream processing的应用程序中,该应用程序也使用Akka HTTP
我在运行时遇到了一个依赖性问题。特别是,当我尝试使用Mongo连接器提供的MongoSink.insertOne方法时,我得到了某种Success/Failure Package 器的NoClassDefFoundError。一个完整的堆栈跟踪:

java.lang.NoClassDefFoundError: com/mongodb/reactivestreams/client/Success
    at akka.stream.alpakka.mongodb.scaladsl.MongoFlow$.$anonfun$insertOne$1(MongoFlow.scala:44)
    at akka.stream.impl.fusing.Map$$anon$1.onPush(Ops.scala:53)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
    at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:423)
    at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:625)
    at akka.stream.impl.fusing.ActorGraphInterpreter$SimpleBoundaryEvent.execute(ActorGraphInterpreter.scala:56)
    at akka.stream.impl.fusing.ActorGraphInterpreter$SimpleBoundaryEvent.execute$(ActorGraphInterpreter.scala:52)
    at akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary$OnNext.execute(ActorGraphInterpreter.scala:95)
    at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:600)
    at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:769)
    at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:784)
    at akka.actor.Actor.aroundReceive(Actor.scala:537)
    at akka.actor.Actor.aroundReceive$(Actor.scala:535)
    at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:691)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:577)
    at akka.actor.ActorCell.invoke(ActorCell.scala:547)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
    at akka.dispatch.Mailbox.run(Mailbox.scala:231)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.ClassNotFoundException: com.mongodb.reactivestreams.client.Success
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 24 more

相关性:

val akkaHttpVersion = "10.2.1"
val akkaVersion = "2.6.10"
val scalaTestVersion = "3.2.0"
val scalaHtmlScraperVersion = "2.2.0"
val loggerVersion = "1.2.3"
val alpakkaMongoVersion = "2.0.2"

libraryDependencies ++= Seq(
  "org.mongodb.scala" %% "mongo-scala-driver" % "4.1.1",
  "com.typesafe.akka" %% "akka-stream-typed" % akkaVersion,    
  "com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
  "com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
  "com.lightbend.akka" %% "akka-stream-alpakka-mongodb" % "2.0.2",
  "ch.qos.logback" % "logback-classic" % loggerVersion,
  "org.scalactic" %% "scalactic" % scalaTestVersion,
  "org.scalatest" %% "scalatest" % scalaTestVersion,
 )

我还尝试添加org.mongodb:mongodb-driver-reactivestreams:4.1.1依赖项,但由于某种原因,com.mongodb.reactivestreams.client.Success不是二进制文件的一部分。我还尝试了不同的版本。如果能得到一些帮助,我将不胜感激。我使用的是Scala 2.13.3

332nm8kg

332nm8kg1#

您的问题与Mongo Reactive Streams驱动程序有关。Alpakka使用的版本有点旧(2019年8月13日)。请参阅Alpakka文档中的“直接依赖项”部分:
mongodb-驱动程序-React流1.12.0
在该jar中,您可以找到Success类:

相关问题