Java Play 部署错误

Posted

技术标签:

【中文标题】Java Play 部署错误【英文标题】:Java Play Deployment Error 【发布时间】:2017-11-04 03:27:03 【问题描述】:

当我尝试运行通过运行“activator dist”命令创建的 bat 文件时,出现以下异常。

    Oops, cannot start the server.
    com.google.inject.CreationException: Unable to create injector, see the followin
    g errors:

    1) Error injecting constructor, java.lang.IncompatibleClassChangeError: Inconsis
    tent constant pool data in classfile for class play/shaded/ahc/org/asynchttpclie
    nt/proxy/ProxyServerSelector. Method lambda$static$0(Lplay/shaded/ahc/org/asynch
    ttpclient/uri/Uri;)Lplay/shaded/ahc/org/asynchttpclient/proxy/ProxyServer; at in
    dex 30 is CONSTANT_MethodRef and should be CONSTANT_InterfaceMethodRef
      at play.api.libs.ws.ahc.AsyncHttpClientProvider.<init>(AhcWSModule.scala:40)
      at play.api.libs.ws.ahc.AsyncHttpClientProvider.class(AhcWSModule.scala:39)
      while locating play.api.libs.ws.ahc.AsyncHttpClientProvider
    Caused by: java.lang.IncompatibleClassChangeError: Inconsistent constant pool da
    ta in classfile for class play/shaded/ahc/org/asynchttpclient/proxy/ProxyServerS
    elector. Method lambda$static$0(Lplay/shaded/ahc/org/asynchttpclient/uri/Uri;)Lp
    lay/shaded/ahc/org/asynchttpclient/proxy/ProxyServer; at index 30 is CONSTANT_Me
    thodRef and should be CONSTANT_InterfaceMethodRef
            at play.shaded.ahc.org.asynchttpclient.proxy.ProxyServerSelector.<clinit
    >(ProxyServerSelector.java:21)
            at play.shaded.ahc.org.asynchttpclient.util.ProxyUtils.createProxyServer
    Selector(ProxyUtils.java:130)
            at play.shaded.ahc.org.asynchttpclient.DefaultAsyncHttpClientConfig$Buil
    der.resolveProxyServerSelector(DefaultAsyncHttpClientConfig.java:1092)
            at play.shaded.ahc.org.asynchttpclient.DefaultAsyncHttpClientConfig$Buil
    der.build(DefaultAsyncHttpClientConfig.java:1110)
            at play.api.libs.ws.ahc.AhcConfigBuilder.build(AhcConfig.scala:153)
            at play.api.libs.ws.ahc.AsyncHttpClientProvider.<init>(AhcWSModule.scala
    :64)
            at play.api.libs.ws.ahc.AsyncHttpClientProvider$$FastClassByGuice$$68dd0
    aee.newInstance(<generated>)
            at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassP
    roxy.newInstance(DefaultConstructionProxyFactory.java:89)
            at com.google.inject.internal.ConstructorInjector.provision(ConstructorI
    njector.java:111)
            at com.google.inject.internal.ConstructorInjector.construct(ConstructorI
    njector.java:90)
            at com.google.inject.internal.ConstructorBindingImpl$Factory.get(Constru
    ctorBindingImpl.java:268)
            at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(Pr
    oviderToInternalFactoryAdapter.java:46)
            at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.ja
    va:1092)
            at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(Provi
    derToInternalFactoryAdapter.java:40)
            at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:1
    94)
            at com.google.inject.internal.InternalFactoryToProviderAdapter.get(Inter
    nalFactoryToProviderAdapter.java:41)
            at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInj
    ectorCreator.java:205)
            at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInj
    ectorCreator.java:199)
            at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.ja
    va:1085)
            at com.google.inject.internal.InternalInjectorCreator.loadEagerSingleton
    s(InternalInjectorCreator.java:199)
            at com.google.inject.internal.InternalInjectorCreator.injectDynamically(
    InternalInjectorCreator.java:180)
            at com.google.inject.internal.InternalInjectorCreator.build(InternalInje
    ctorCreator.java:110)
            at com.google.inject.Guice.createInjector(Guice.java:99)
            at com.google.inject.Guice.createInjector(Guice.java:84)
            at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scal
    a:181)
            at play.inject.guice.GuiceBuilder.injector(GuiceBuilder.java:221)
            at play.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuild
    er.java:156)
            at play.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.
    java:34)
            at play.api.ApplicationLoader$JavaApplicationLoaderAdapter$1.load(Applic
    ationLoader.scala:87)
            at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
            at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
            at play.core.server.ProdServerStart.main(ProdServerStart.scala)

    2) Error injecting constructor, java.lang.NoClassDefFoundError: Could not initia
    lize class play.shaded.ahc.org.asynchttpclient.proxy.ProxyServerSelector
      at play.api.libs.ws.ahc.AsyncHttpClientProvider.<init>(AhcWSModule.scala:40)
      at play.api.libs.ws.ahc.AsyncHttpClientProvider.class(AhcWSModule.scala:39)
      while locating play.api.libs.ws.ahc.AsyncHttpClientProvider
      while locating play.shaded.ahc.org.asynchttpclient.AsyncHttpClient
        for the 1st parameter of play.libs.ws.ahc.AhcWSModule$AhcWSClientProvider.<i
    nit>(AhcWSModule.java:40)
      at play.libs.ws.ahc.AhcWSModule$AhcWSClientProvider.class(AhcWSModule.java:35)

      while locating play.libs.ws.ahc.AhcWSModule$AhcWSClientProvider
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class play.shade
    d.ahc.org.asynchttpclient.proxy.ProxyServerSelector
            at play.shaded.ahc.org.asynchttpclient.util.ProxyUtils.createProxyServer
    Selector(ProxyUtils.java:130)
            at play.shaded.ahc.org.asynchttpclient.DefaultAsyncHttpClientConfig$Buil
    der.resolveProxyServerSelector(DefaultAsyncHttpClientConfig.java:1092)
            at play.shaded.ahc.org.asynchttpclient.DefaultAsyncHttpClientConfig$Buil
    der.build(DefaultAsyncHttpClientConfig.java:1110)
            at play.api.libs.ws.ahc.AhcConfigBuilder.build(AhcConfig.scala:153)
            at play.api.libs.ws.ahc.AsyncHttpClientProvider.<init>(AhcWSModule.scala
    :64)
            at play.api.libs.ws.ahc.AsyncHttpClientProvider$$FastClassByGuice$$68dd0
    aee.newInstance(<generated>)
            at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassP
    roxy.newInstance(DefaultConstructionProxyFactory.java:89)
            at com.google.inject.internal.ConstructorInjector.provision(ConstructorI
    njector.java:111)
            at com.google.inject.internal.ConstructorInjector.construct(ConstructorI
    njector.java:90)
            at com.google.inject.internal.ConstructorBindingImpl$Factory.get(Constru
    ctorBindingImpl.java:268)
            at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(Pr
    oviderToInternalFactoryAdapter.java:46)
            at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.ja
    va:1092)
            at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(Provi
    derToInternalFactoryAdapter.java:40)
            at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:1
    94)
            at com.google.inject.internal.InternalFactoryToProviderAdapter.get(Inter
    nalFactoryToProviderAdapter.java:41)
            at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFact
    ory.java:61)
            at com.google.inject.internal.SingleParameterInjector.inject(SingleParam
    eterInjector.java:38)
            at com.google.inject.internal.SingleParameterInjector.getAll(SingleParam
    eterInjector.java:62)
            at com.google.inject.internal.ConstructorInjector.provision(ConstructorI
    njector.java:110)
            at com.google.inject.internal.ConstructorInjector.construct(ConstructorI
    njector.java:90)
            at com.google.inject.internal.ConstructorBindingImpl$Factory.get(Constru
    ctorBindingImpl.java:268)
            at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(Pr
    oviderToInternalFactoryAdapter.java:46)
            at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.ja
    va:1092)
            at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(Provi
    derToInternalFactoryAdapter.java:40)
            at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:1
    94)
            at com.google.inject.internal.InternalFactoryToProviderAdapter.get(Inter
    nalFactoryToProviderAdapter.java:41)
            at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInj
    ectorCreator.java:205)
            at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInj
    ectorCreator.java:199)
            at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.ja
    va:1085)
            at com.google.inject.internal.InternalInjectorCreator.loadEagerSingleton
    s(InternalInjectorCreator.java:199)
            at com.google.inject.internal.InternalInjectorCreator.injectDynamically(
    InternalInjectorCreator.java:180)
            at com.google.inject.internal.InternalInjectorCreator.build(InternalInje
    ctorCreator.java:110)
            at com.google.inject.Guice.createInjector(Guice.java:99)
            at com.google.inject.Guice.createInjector(Guice.java:84)
            at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scal
    a:181)
            at play.inject.guice.GuiceBuilder.injector(GuiceBuilder.java:221)
            at play.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuild
    er.java:156)
            at play.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.
    java:34)
            at play.api.ApplicationLoader$JavaApplicationLoaderAdapter$1.load(Applic
    ationLoader.scala:87)
            at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
            at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
            at play.core.server.ProdServerStart.main(ProdServerStart.scala)

    3) Error injecting constructor, java.lang.NoClassDefFoundError: Could not initia
    lize class play.shaded.ahc.org.asynchttpclient.proxy.ProxyServerSelector
      at play.api.libs.ws.ahc.AsyncHttpClientProvider.<init>(AhcWSModule.scala:40)
      at play.api.libs.ws.ahc.AsyncHttpClientProvider.class(AhcWSModule.scala:39)
      while locating play.api.libs.ws.ahc.AsyncHttpClientProvider
      while locating play.shaded.ahc.org.asynchttpclient.AsyncHttpClient
        for the 1st parameter of play.api.libs.ws.ahc.AhcWSClientProvider.<init>(Ahc
    WSModule.scala:203)
      at play.api.libs.ws.ahc.AhcWSClientProvider.class(AhcWSModule.scala:203)
      while locating play.api.libs.ws.ahc.AhcWSClientProvider
    Caused by: java.lang.NoClassDefFoundError (same stack trace as error #2)
    3 errors
            at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist
    (Errors.java:470)
            at com.google.inject.internal.InternalInjectorCreator.injectDynamically(
    InternalInjectorCreator.java:184)
            at com.google.inject.internal.InternalInjectorCreator.build(InternalInje
    ctorCreator.java:110)
            at com.google.inject.Guice.createInjector(Guice.java:99)
            at com.google.inject.Guice.createInjector(Guice.java:84)
            at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scal
    a:181)
            at play.inject.guice.GuiceBuilder.injector(GuiceBuilder.java:221)
            at play.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuild
    er.java:156)
            at play.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.
    java:34)
            at play.api.ApplicationLoader$JavaApplicationLoaderAdapter$1.load(Applic
    ationLoader.scala:87)
            at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
            at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
            at play.core.server.ProdServerStart.main(ProdServerStart.scala)
    08:51:10.492 [application-akka.actor.default-dispatcher-8] INFO  akka.actor.Coor
    dinatedShutdown - Starting coordinated shutdown from JVM shutdown hook
    08:51:10.492 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [before-service-unbind] with [0] tasks
    08:51:10.508 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [service-unbind] with [0] tasks
    08:51:10.508 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [service-requests-done] with [0] tasks
    08:51:10.508 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [service-stop] with [0] tasks
    08:51:10.508 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [before-cluster-shutdown] with [0] tasks
    08:51:10.523 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [cluster-sharding-shutdown-region] with [0] t
    asks
    08:51:10.523 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [cluster-leave] with [0] tasks
    08:51:10.539 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [cluster-exiting] with [0] tasks
    08:51:10.539 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [cluster-exiting-done] with [0] tasks
    08:51:10.539 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [cluster-shutdown] with [0] tasks
    08:51:10.539 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [before-actor-system-terminate] with [0] task
    s
    08:51:10.555 [application-akka.actor.default-dispatcher-8] DEBUG akka.actor.Coor
    dinatedShutdown - Performing phase [actor-system-terminate] with [1] tasks: [ter
    minate-system]

但是当我在我的机器上执行时,它运行良好。我在这里做错了什么?我尝试过更改端口,但仍然没有运气。下面是我用来运行 bat 文件的命令。

 myApplication.bat -Dhttp.port=9999

任何帮助将不胜感激。

【问题讨论】:

【参考方案1】:

这是由于 sbt 插件和 ebean 插件版本之间的版本冲突而导致的错误。我能够使用当前可用的最新版本解决此问题。

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.0.6")

另外,我使用 Java 9 可能会导致 java.xml.bind 模块出错。请参阅此问题以解决该错误。 Scala incompatibility with Java 9 - java.lang.NoClassDefFoundError

【讨论】:

以上是关于Java Play 部署错误的主要内容,如果未能解决你的问题,请参考以下文章

Android Instant App - Play Console 发布/部署错误和 DAL(数字资产链接)未链接

play2.0 + java + mysql5.0 错误太多

Play framework 2.0.1 不断尝试进化错误的数据库类型

在play框架中,无法编译文件XX.java。引发的错误是:无法在 Eclipse 中解析导入 XXX

Google Play 服务更新到版本 13 后,出现错误

Play中xxx cannot be resolved to a type 错误解决方法