Play-Framework:2.3.x:play - 无法调用动作,最终出错:java.lang.IllegalArgumentException:

时间:2015-04-26 07:05:58

标签: scala playframework-2.3 reactivemongo

我正在使用play-framework 2.3.x reactivemongo-extension JSON type。以下是我从db获取数据的代码,如下所示:

def getStoredAccessToken(authInfo: AuthInfo[User]) = {
println(">>>>>>>>>>>>>>>>>>>>>>: BEFORE"); //$doc("clientId" $eq authInfo.user.email, "userId" $eq authInfo.user._id.get)
var future = accessTokenService.findRandom(Json.obj("clientId" -> authInfo.user.email, "userId" -> authInfo.user._id.get));
println(">>>>>>>>>>>>>>>>>>>>>>: AFTER: "+future);
future.map { option => {
  println("*************************** ")
  println("***************************: "+option.isEmpty)
  if (!option.isEmpty){
   var accessToken = option.get;println(">>>>>>>>>>>>>>>>>>>>>>: BEFORE VALUE");
   var value = Crypto.validateToken(accessToken.createdAt.value)
   println(">>>>>>>>>>>>>>>>>>>>>>: "+value);
   Some(scalaoauth2.provider.AccessToken(accessToken.accessToken, accessToken.refreshToken, authInfo.scope, 
       Some(value), new Date(accessToken.createdAt.value)))
  }else{
    Option.empty
  }
}}

}

当我使用BSONDaoBsonDocument获取数据时,此代码已成功运行,但转换为JSONDao后,我收到以下错误:

注意:有时候这段代码会运行,但有些时候会在转换为JSON后抛出异常

play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: bound must be positive
application - 

以下是应用程序完全异常删除跟踪的日志,如下所示:

>>>>>>>>>>>>>>>>>>>>>>: BEFORE
>>>>>>>>>>>>>>>>>>>>>>: AFTER:   scala.concurrent.impl.Promise$DefaultPromise@7f4703e3
play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: bound must be positive
application - 
! @6m1520jff - Internal server error, for (POST) [/oauth2/token] ->
play.api.Application$$anon$1: Execution exception[[IllegalArgumentException: bound must be positive]]
at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.8.jar:2.3.8]
at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.8.jar:2.3.8]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.8.jar:2.3.8]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.8.jar:2.3.8]
at scala.Option.map(Option.scala:146) [scala-library-2.11.6.jar:na]
Caused by: java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388) ~[na:1.8.0_40]
at scala.util.Random.nextInt(Random.scala:66) ~[scala-library-2.11.6.jar:na]

1 个答案:

答案 0 :(得分:0)

问题解决了,但我不确定,为什么这会产生,我认为JPanel库存在问题。因为当我使用reactivemongo-extension JSONDao代替findOne时代码运行成功,但findRandom在BSON dao上运行良好。仍然没有找到确切的问题是什么,但以下是已解决的代码。

findRandom

}