获取错误java.lang.ClassNotFoundException:AppLoader

时间:2018-06-19 08:27:41

标签: java playframework-2.6

我正在使用自定义应用加载器。

play.application.loader="AppLoader"

我的java.lang.ClassNotFoundException: AppLoader应用程序出现play错误。该应用程序之前工作正常。

堆栈跟踪

! @78am4d92i - Internal server error, for (GET) [/] ->

play.api.PlayException: Cannot load play.application.loader[play.application.loader [AppLoader] was not loaded.]
    at play.utils.Reflect$.loadClass$1(Reflect.scala:111)
    at play.utils.Reflect$.configuredClass(Reflect.scala:124)
    at play.api.ApplicationLoader$.apply(ApplicationLoader.scala:73)
    at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:173)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:171)
    at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
    at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:189)
    at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:106)
    at akka.stream.impl.fusing.MapAsync$$anon$25.onPush(Ops.scala:1194)
Caused by: java.lang.ClassNotFoundException: AppLoader
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at play.utils.Reflect$.loadClass$1(Reflect.scala:105)
    at play.utils.Reflect$.configuredClass(Reflect.scala:124)
    at play.api.ApplicationLoader$.apply(ApplicationLoader.scala:73)
    at play.core.server.DevServerStart$$anon$1.$anonfun$reload$3(DevServerStart.scala:173)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:171)
    at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)
[error] application - 

1 个答案:

答案 0 :(得分:0)

我的问题是我没有正确引用该类。我之前的代码将application.conf中的类引用为play.application.loader="AppLoader"。后来我将AppLoader移到了app包中,但是我忘记更改application.conf中的条目。我不得不将其更改为play.application.loader="app.AppLoader"