在生产模式下运行Play框架时出错

时间:2017-10-13 10:35:54

标签: playframework playframework-2.0

我从dist运行生产时遇到错误,但它在开发模式和相同DB的同一系统中工作。

sudo ./sampleapp -Dhttp.port=9010  -J-Xms128M -J-Xmx512m -J-server
  

密码:       [info] application - 为数据源创建池'默认'       [错误] c.z.h.p.HikariPool - HikariPool-1 - 池初始化期间的异常。       com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:拒绝访问用户'' localhost'到数据库&ariscu_ftalent'         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)         在com.mysql.jdbc.Util.handleNewInstance(Util.java:411)         在com.mysql.jdbc.Util.getInstance(Util.java:386)         在com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)       [info] application - 为数据源创建池'默认'       [错误] c.z.h.p.HikariPool - HikariPool-2 - 池初始化期间的异常。       com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:拒绝访问用户'' localhost'到数据库&ariscu_ftalent'         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)         在com.mysql.jdbc.Util.handleNewInstance(Util.java:411)         在com.mysql.jdbc.Util.getInstance(Util.java:386)         在com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)       哎呀,无法启动服务器。       配置错误:配置错误[无法连接到数据库[默认]]         at play.api.Configuration $ .configError(Configuration.scala:155)         at play.api.Configuration.reportError(Configuration.scala:984)         at play.api.db.DefaultDBApi。$ anonfun $ connect $ 1(DefaultDBApi.scala:48)         at play.api.db.DefaultDBApi。$ anonfun $ connect $ 1 $ adapted(DefaultDBApi.scala:42)         在scala.collection.immutable.List.foreach(List.scala:389)         at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42)         at play.api.db.DBApiProvider.get $ lzycompute(DBModule.scala:86)         at play.api.db.DBApiProvider.get(DBModule.scala:75)         at play.api.db.DBApiProvider.get(DBModule.scala:56)         在com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)         在com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)         在com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)         在com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)         在com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)         在com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)         在com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:110)         在com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)         在com.google.inject.internal.ConstructorBindingImpl $ Factory.get(ConstructorBindingImpl.java:268)         在com.google.inject.internal.ProviderToInternalFactoryAdapter $ 1.call(ProviderToInternalFactoryAdapter.java:46)         在com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)         在com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)         在com.google.inject.internal.SingletonScope $ 1.get(SingletonScope.java:194)         在com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)         在com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)         在com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:54)         在com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132)         在com.google.inject.internal.MembersInjectorImpl $ 1.call(MembersInjectorImpl.java:93)         在com.google.inject.internal.MembersInjectorImpl $ 1.call(MembersInjectorImpl.java:80)         在com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)         在com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80)         在com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:62)         在com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:987)         在com.google.inject.util.Providers $ GuicifiedProviderWithDependencies.initialize(Providers.java:149)         在com.google.inject.util.Providers $ GuicifiedProviderWithDependencies $$ FastClassByGuice $$ 2a7177aa.invoke()         在com.google.inject.internal.SingleMethodInjector $ 1.invoke(SingleMethodInjector.java:54)         在com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:89)         在com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132)         在com.google.inject.internal.MembersInjectorImpl $ 1.call(MembersInjectorImpl.java:93)         在com.google.inject.internal.MembersInjectorImpl $ 1.call(MembersInjectorImpl.java:80)         在com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)         在com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80)         在com.google.inject.internal.Initializer $ InjectableReference.get(Initializer.java:223)         在com.google.inject.internal.Initializer.injectAll(Initializer.java:132)         在com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:174)         在com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)         在com.google.inject.Guice.createInjector(Guice.java:99)         在com.google.inject.Guice.createInjector(Guice.java:84)         at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:185)         at play.inject.guice.GuiceBuilder.injector(GuiceBuilder.java:221)         at play.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.java:156)         在modules.LogSdtErrLoader.load(LogSdtErrLoader.java:29)         at play.api.ApplicationLoader $ JavaApplicationLoaderAdapter $ 1.load(ApplicationLoader.scala:87)         at play.core.server.ProdServerStart $ .start(ProdServerStart.scala:50)         at play.core.server.ProdServerStart $ .main(ProdServerStart.scala:25)         在play.core.server.ProdServerStart.main(ProdServerStart.scala)       原因:配置错误:配置错误[无法初始化池:用户访问被拒绝'' localhost'到数据库   ' arisetec_ftalent']         at play.api.Configuration $ .configError(Configuration.scala:155)         at play.api.Configuration.reportError(Configuration.scala:984)         at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:63)         at play.api.db.PooledDatabase.createDataSource(Databases.scala:199)         at play.api.db.DefaultDatabase.dataSource $ lzycompute(Databases.scala:123)         at play.api.db.DefaultDatabase.dataSource(Databases.scala:121)         at play.api.db.DefaultDatabase.getConnection(Databases.scala:142)         at play.api.db.DefaultDatabase.getConnection(Databases.scala:138)         at play.api.db.DefaultDBApi。$ anonfun $ connect $ 1(DefaultDBApi.scala:44)         ......还有52个       引起:com.zaxxer.hikari.pool.HikariPool $ PoolInitializationException:失败   初始化池:用户访问被拒绝'' localhost'到数据库   ' arisetec_ftalent'         在com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:543)         在com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:535)         在com.zaxxer.hikari.pool.HikariPool。(HikariPool.java:111)         在com.zaxxer.hikari.HikariDataSource。(HikariDataSource.java:72)         at play.api.db.HikariCPConnectionPool。$ anonfun $ create $ 1(HikariCPModule.scala:51)         在scala.util.Try $ .apply(Try.scala:209)         at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:47)         ......还有58个       引起:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Access   拒绝用户' @' localhost'到数据库&ariscu_ftalent'         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)         在com.mysql.jdbc.Util.handleNewInstance(Util.java:411)         在com.mysql.jdbc.Util.getInstance(Util.java:386)         在com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)         在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)         在com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)         在com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)         在com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)         在com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)         在com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)         在com.mysql.jdbc.ConnectionImpl。(ConnectionImpl.java:792)         在com.mysql.jdbc.JDBC4Connection。(JDBC4Connection.java:47)         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)         在com.mysql.jdbc.Util.handleNewInstance(Util.java:411)         在com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)         在com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)         在com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:112)         在com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)         在com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)         在com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:443)         在com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:514)         ... 63更多

1 个答案:

答案 0 :(得分:1)

生产环境中的数据库配置缺少数据库用户的用户名。仔细查看错误消息:

  

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:用户''@ localhost'拒绝访问数据库'aristec_ftalent'

它说

  

用户访问被拒绝'' @'localhost'

用户名为空。请检查您的配置。