我正在调用在Spark Future中具有NTLM Auth的Web API。 我无法分享确切的代码,但是下面是我将来调用的示例方法
def ApiCall(Paramters)
{
val post = new HttpPost( Web Api Link)
post.setEntity(new StringEntity(JsonInput_String,
ContentType.APPLICATION_JSON))
val credsProvider = new BasicCredentialsProvider
val credential = new NTCredentials(UserID,Password)
credsProvider.setCredentials(AuthScope.ANY, credential)
val HttpBuilder= HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build()
val httpResponse = HttpBuilder.execute(post)
//putting result of API to a List
}
And then I am calling this method in a loop
val Ft:Seq[Future[Int]] = for (Looping condt) yield
{
Future { ApiCall(some parameters)
1
}
val Aggregated: Future[Seq[Int]] = Future.sequence(Ft)
Await.result(Aggregated, 2.hours)
但是我遇到了以下错误:
19/01/03 10:10:56 ERROR ApplicationMaster: User class threw exception: java.lang.ArrayIndexOutOfBoundsException: 40
java.lang.ArrayIndexOutOfBoundsException: 40
at org.apache.http.impl.auth.NTLMEngineImpl$NTLMMessage.addByte(NTLMEngineImpl.java:911)
at org.apache.http.impl.auth.NTLMEngineImpl$NTLMMessage.addULong(NTLMEngineImpl.java:941)
at org.apache.http.impl.auth.NTLMEngineImpl$Type1Message.getResponse(NTLMEngineImpl.java:1036)
at org.apache.http.impl.auth.NTLMEngineImpl.getType1Message(NTLMEngineImpl.java:148)
at org.apache.http.impl.auth.NTLMEngineImpl.generateType1Msg(NTLMEngineImpl.java:1628)
at org.apache.http.impl.auth.NTLMScheme.authenticate(NTLMScheme.java:139)
at org.apache.http.impl.auth.AuthSchemeBase.authenticate(AuthSchemeBase.java:138)
at org.apache.http.impl.auth.HttpAuthenticator.doAuth(HttpAuthenticator.java:239)
at org.apache.http.impl.auth.HttpAuthenticator.generateAuthResponse(HttpAuthenticator.java:202)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:262)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at SymbolLinking.SymbolLinking$$anonfun$1.apply(SymbolLinking.scala:458)
at SymbolLinking.SymbolLinking$$anonfun$1.apply(SymbolLinking.scala:324)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:108)
at SymbolLinking.SymbolLinking.ApiCall(SymbolLinking.scala:324)
at SymbolLinking.SymbolLinking$$anonfun$2$$anonfun$apply$1.apply$mcI$sp(SymbolLinking.scala:569)
at SymbolLinking.SymbolLinking$$anonfun$2$$anonfun$apply$1.apply(SymbolLinking.scala:569)
at SymbolLinking.SymbolLinking$$anonfun$2$$anonfun$apply$1.apply(SymbolLinking.scala:569)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107)
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)
19/01/03 10:10:56 INFO ApplicationMaster: Final app status: FAILED, exitCode: 15, (reason: User class threw exception: java.lang.ArrayIndexOutOfBoundsException: 40)
19/01/03 10:10:56 INFO SparkContext: Invoking stop() from shutdown hook