我是Amazon Kinesis的新手。我已经阅读了基本文档和Kinesis APi以开始使用Kinesis。所以我在scala中编写了一小段代码来创建一个流。但我面临一个例外,如下所示
线程中的异常" main" java.lang.NoSuchMethodError:org.joda.time.format.DateTimeFormatter.withZoneUTC()Lorg / joda / time / format / DateTimeFormatter; 在com.amazonaws.auth.AWS4Signer。(AWS4Signer.java:44) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 在java.lang.Class.newInstance(Class.java:379) 在com.amazonaws.auth.SignerFactory.createSigner(SignerFactory.java:119) 在com.amazonaws.auth.SignerFactory.lookupAndCreateSigner(SignerFactory.java:105) 在com.amazonaws.auth.SignerFactory.getSigner(SignerFactory.java:78) 在com.amazonaws.AmazonWebServiceClient.computeSignerByServiceRegion(AmazonWebServiceClient.java:307) 在com.amazonaws.AmazonWebServiceClient.computeSignerByURI(AmazonWebServiceClient.java:280) 在com.amazonaws.AmazonWebServiceClient.setEndpoint(AmazonWebServiceClient.java:160) 在com.amazonaws.services.kinesis.AmazonKinesisClient.setEndpoint(AmazonKinesisClient.java:2102) 在com.amazonaws.services.kinesis.AmazonKinesisClient.init(AmazonKinesisClient.java:216) 在com.amazonaws.services.kinesis.AmazonKinesisClient。(AmazonKinesisClient.java:139) 在com.amazonaws.services.kinesis.AmazonKinesisClient。(AmazonKinesisClient.java:116) 在com.platalytics.platform.connectors.Kinesis.App $ .create(App.scala:32) 在com.platalytics.platform.connectors.Kinesis.App $ .main(App.scala:26) 在com.platalytics.platform.connectors.Kinesis.App.main(App.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:606)
这是我的代码
def main(args: Array[String]) {
println("Stream creation started")
if(create(2))
println("Stream is created successfully")
}
def create(shardCount: Int): Boolean = {
val credentials = new BasicAWSCredentials(KinesisProperties.AWS_ACCESS_KEY_ID, KinesisProperties.AWS_SECRET_KEY)
var kinesisClient: AmazonKinesisClient = new AmazonKinesisClient(credentials)
kinesisClient.setEndpoint(KinesisProperties.KINESIS_ENDPOINT_URL,
KinesisProperties.KINESIS_SERVICE_NAME,
KinesisProperties.KINESIS_REGION_ID)
val createStreamRequest = new CreateStreamRequest()
createStreamRequest.setStreamName(KinesisProperties.myStreamName);
createStreamRequest.setShardCount(shardCount)
val describeStreamRequest = new DescribeStreamRequest()
describeStreamRequest.setStreamName(KinesisProperties.myStreamName)
try {
Thread.sleep(120000)
} catch {
case e: Exception =>
}
var streamStatus = "not active"
while (!streamStatus.equalsIgnoreCase("ACTIVE")) {
try {
Thread.sleep(1000)
} catch {
case e: Exception => e.printStackTrace()
}
try {
val describeStreamResponse = kinesisClient.describeStream(describeStreamRequest)
streamStatus = describeStreamResponse.getStreamDescription.getStreamStatus
} catch {
case e: Exception => e.printStackTrace()
}
}
if (streamStatus.equalsIgnoreCase("ACTIVE"))
true
else
false
}
这是我在pom文件中的依赖项
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-kinesis-client</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.8.9</version>
</dependency>
答案 0 :(得分:0)
各位好友我通过将joda-time jar文件添加到HADOOP_CLASSPATH找到了解决此问题的方法。现在它正在工作