播放框架2.4迁移,org.apache.commons.codec.digest的NoSuchMethodError

时间:2015-11-14 00:58:22

标签: java playframework

您好我最近从2.3.8迁移到2.4.0(使用Activator 1.3.6播放框架)。我有2个类似的项目。我升级了第一个没有任何错误。但是,第二个项目给了我这个错误:

  

NoSuchMethodError:org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava / lang / String;)Ljava / lang / String;

没有指向我的代码的堆栈跟踪。在Web调试器中它说

  

没有可用的源,这是异常堆栈跟踪:

我无法弄清楚出了什么问题。有谁之前经历过这个吗? 这是我在(成功)编译和运行应用程序后看到的屏幕截图:

enter image description here

我按照这里给出的步骤进行了操作:

https://www.playframework.com/documentation/2.4.x/Migration24 https://www.playframework.com/documentation/2.4.x/JavaEbean

感谢任何帮助。谢谢你的时间。

[更新]当我禁用evolutions插件时,错误就会消失。每当我在applicatin.conf中将其设置为false时

  

play.evolutions.enabled =假

该应用似乎有效。我相信evolutions插件存在一些问题。不知道如何解决这个问题。

更新: 虽然应用程序似乎现在运行,但它在从资产调用任何文件时给出了同样的错误。因此,我的样式没有编译。 在此处查看浏览器控制台日志: enter image description here

我正在记录来自Global.java的错误消息并输出错误。终端输出如下: enter image description here

我的build.sbt如下:

name := """PROJECT_NAME"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava,PlayEbean,SbtWeb)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs
)

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.29"

libraryDependencies += "commons-codec" % "commons-codec" % "1.10"

libraryDependencies += evolutions

includeFilter in (Assets, LessKeys.less) := "*.less"

excludeFilter in (Assets, LessKeys.less) := "_*.less"

我在Global.java中记录的错误的堆栈跟踪:

[ERROR] MESSAGE: java.lang.NoSuchMethodError: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String;  CAUSED BY : java.lang.NoSuchMethodError: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String; STACK TRACE BELOW: 

play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96)
play.api.libs.iteratee.DoneIteratee$$anonfun$mapM$2.apply(Iteratee.scala:741)
play.api.libs.iteratee.DoneIteratee$$anonfun$mapM$2.apply(Iteratee.scala:741)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:498)
akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105)
play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:105)
play.utils.Threads$.withContextClassLoader(Threads.scala:21)
play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:104)
play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:103)
scala.Option.map(Option.scala:146)
play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:103)
play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:96)
play.api.libs.iteratee.DoneIteratee$$anonfun$mapM$2.apply(Iteratee.scala:741)
play.api.libs.iteratee.DoneIteratee$$anonfun$mapM$2.apply(Iteratee.scala:741)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

1 个答案:

答案 0 :(得分:2)

看起来您使用的是旧版本的Apache Commons,它还没有sha1Hex()函数。通过将commons-codec 1.10版添加到build.sbt来尝试更新的。

libraryDependencies ++= Seq(
  ...
  "commons-codec" % "commons-codec" % "1.10",
  ...
)