我正在尝试构建一个简单的应用程序,它将使用KPL向Kinesis生成消息。我在scala中写这个,并收到一条我似乎无法弄清楚的错误信息。我的代码如下:
import java.nio.ByteBuffer
import com.amazonaws.services.kinesis.producer.{KinesisProducer, KinesisProducerConfiguration}
object KinesisStream extends App{
ProduceToKinesis()
def ProduceToKinesis(): Unit ={
val config = new KinesisProducerConfiguration()
val kinesis = new KinesisProducer(config)
val data = ByteBuffer.wrap("myData".getBytes("UTF-8"))
kinesis.addUserRecord("TestStream", "myPartitionKey", data)
}
}
它失败了
val kinesis = new KinesisProducer(config)
,错误消息为:
Exception in thread "main" java.lang.RuntimeException: Could not copy native binaries to temp directory C:\Users\************\AppData\Local\Temp\amazon-kinesis-producer-native-binaries
at com.amazonaws.services.kinesis.producer.KinesisProducer.extractBinaries(KinesisProducer.java:844)
at com.amazonaws.services.kinesis.producer.KinesisProducer.<init>(KinesisProducer.java:242)
at KinesisStream$.ProduceToKinesis(KinesisStream.scala:14)
at KinesisStream$.delayedEndpoint$KinesisStream$1(KinesisStream.scala:9)
at KinesisStream$delayedInit$body.apply(KinesisStream.scala:8)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at KinesisStream$.main(KinesisStream.scala:8)
at KinesisStream.main(KinesisStream.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.NullPointerException
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:462)
at com.amazonaws.services.kinesis.producer.KinesisProducer.extractBinaries(KinesisProducer.java:803)
... 18 more
我的Build.SBT看起来像这样:
name := "Kinesis"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies += "com.amazonaws" % "amazon-kinesis-producer" % "0.12.1"