将play framework 2.4 app部署到heroku

时间:2015-08-19 18:02:00

标签: java postgresql heroku playframework-2.0 typesafe-activator

大家好,我在将应用程序部署到heroku时遇到了一些麻烦。 我尝试打开它时收到以下日志错误。

    2015-08-19T17:49:04.031456+00:00 app[web.1]:    at com.google.inject.internal.Si
ngleMethodInjector$1.invoke(SingleMethodInjector.java:57)
2015-08-19T17:49:04.031466+00:00 app[web.1]:    at com.google.inject.internal.In
itializer.injectAll(Initializer.java:108)
2015-08-19T17:49:04.031447+00:00 app[web.1]:    at com.google.inject.internal.In
jectorImpl.callInContext(InjectorImpl.java:1103)
2015-08-19T17:49:04.031462+00:00 app[web.1]:    at com.google.inject.internal.In
jectorImpl.callInContext(InjectorImpl.java:1092)
2015-08-19T17:49:04.031238+00:00 app[web.1]:    at com.zaxxer.hikari.pool.Hikari
Pool.<init>(HikariPool.java:60)
2015-08-19T17:49:04.031239+00:00 app[web.1]:    at com.zaxxer.hikari.pool.Hikari
Pool.<init>(HikariPool.java:48)
2015-08-19T17:49:04.031241+00:00 app[web.1]:    at com.zaxxer.hikari.HikariDataS
ource.<init>(HikariDataSource.java:80)
2015-08-19T17:49:04.031242+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool$$anonfun$1.apply(HikariCPModule.scala:58)
2015-08-19T17:49:04.031243+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool$$anonfun$1.apply(HikariCPModule.scala:54)
2015-08-19T17:49:04.031244+00:00 app[web.1]:    at scala.util.Try$.apply(Try.sca
la:191)
2015-08-19T17:49:04.031245+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool.create(HikariCPModule.scala:54)
2015-08-19T17:49:04.031247+00:00 app[web.1]:    ... 47 more
2015-08-19T17:49:04.031248+00:00 app[web.1]: Caused by: java.sql.SQLException: J
DBC4 Connection.isValid() method not supported, connection test query must be co
nfigured
2015-08-19T17:49:04.031249+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHi
kariPool.addConnection(BaseHikariPool.java:441)
2015-08-19T17:49:04.031251+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHi
kariPool.initializeConnections(BaseHikariPool.java:540)
2015-08-19T17:49:04.031252+00:00 app[web.1]:    ... 55 more
2015-08-19T17:49:04.031253+00:00 app[web.1]:
2015-08-19T17:49:04.031254+00:00 app[web.1]: 2) Error in custom provider, Config
uration error: Configuration error[Cannot connect to database [default]]
2015-08-19T17:49:04.031256+00:00 app[web.1]:   while locating play.api.db.DBApiP
rovider
2015-08-19T17:49:04.031257+00:00 app[web.1]:   while locating play.api.db.DBApi
2015-08-19T17:49:04.031258+00:00 app[web.1]:     for parameter 0 at play.db.Defa
ultDBApi.<init>(DefaultDBApi.java:28)
2015-08-19T17:49:04.031260+00:00 app[web.1]:   at play.db.DefaultDBApi.class(Def
aultDBApi.java:28)
2015-08-19T17:49:04.031261+00:00 app[web.1]:   while locating play.db.DefaultDBA
pi
2015-08-19T17:49:04.031262+00:00 app[web.1]:   while locating play.db.DBApi
2015-08-19T17:49:04.031264+00:00 app[web.1]:     for field at play.db.DBModule$N
amedDatabaseProvider.dbApi(DBModule.java:61)
2015-08-19T17:49:04.031265+00:00 app[web.1]:   while locating play.db.DBModule$N
amedDatabaseProvider
2015-08-19T17:49:04.031267+00:00 app[web.1]:   at com.google.inject.util.Provide
rs$GuicifiedProviderWithDependencies.initialize(Providers.java:149)
2015-08-19T17:49:04.031268+00:00 app[web.1]:   at play.db.DBModule.bindings(DBMo
dule.java:40):
2015-08-19T17:49:04.031269+00:00 app[web.1]: Binding(interface play.db.Database
qualified with QualifierInstance(@play.db.NamedDatabase(value=default)) to Provi
derTarget(play.db.DBModule$NamedDatabaseProvider@5cbf9e9f)) (via modules: com.go
ogle.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModule
Conversions$$anon$1)
2015-08-19T17:49:04.031271+00:00 app[web.1]: Caused by: Configuration error: Con
figuration error[Cannot connect to database [default]]
2015-08-19T17:49:04.031272+00:00 app[web.1]:    at play.api.Configuration$.confi
gError(Configuration.scala:178)
2015-08-19T17:49:04.031273+00:00 app[web.1]:    at play.api.Configuration.report
Error(Configuration.scala:829)
2015-08-19T17:49:04.031274+00:00 app[web.1]:    at play.api.db.DefaultDBApi$$ano
nfun$connect$1.apply(DefaultDBApi.scala:48)
2015-08-19T17:49:04.031276+00:00 app[web.1]:    at play.api.db.DefaultDBApi$$ano
nfun$connect$1.apply(DefaultDBApi.scala:42)
2015-08-19T17:49:04.031277+00:00 app[web.1]:    at scala.collection.immutable.Li
st.foreach(List.scala:381)
2015-08-19T17:49:04.031278+00:00 app[web.1]:    at play.api.db.DefaultDBApi.conn
ect(DefaultDBApi.scala:42)
2015-08-19T17:49:04.031280+00:00 app[web.1]:    at play.api.db.DBApiProvider.get
$lzycompute(DBModule.scala:72)
2015-08-19T17:49:04.031281+00:00 app[web.1]:    at play.api.db.DBApiProvider.get
(DBModule.scala:62)
2015-08-19T17:49:04.031282+00:00 app[web.1]:    at play.api.db.DBApiProvider.get
(DBModule.scala:58)
2015-08-19T17:49:04.031283+00:00 app[web.1]:    at com.google.inject.internal.Pr
oviderInternalFactory.provision(ProviderInternalFactory.java:81)
2015-08-19T17:49:04.031288+00:00 app[web.1]:    at com.google.inject.internal.Bo
undProviderFactory.provision(BoundProviderFactory.java:72)
2015-08-19T17:49:04.031424+00:00 app[web.1]:    at com.google.inject.internal.Pr
oviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
2015-08-19T17:49:04.031426+00:00 app[web.1]:    at com.google.inject.internal.Bo
undProviderFactory.get(BoundProviderFactory.java:62)
2015-08-19T17:49:04.031450+00:00 app[web.1]:    at com.google.inject.internal.Me
mbersInjectorImpl.injectMembers(MembersInjectorImpl.java:62)
2015-08-19T17:49:04.031467+00:00 app[web.1]:    at com.google.inject.internal.In
ternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:174)
2015-08-19T17:49:04.031463+00:00 app[web.1]:    at com.google.inject.internal.Me
mbersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80)
2015-08-19T17:49:04.031476+00:00 app[web.1]:    at play.api.inject.guice.GuiceAp
plicationLoader.load(GuiceApplicationLoader.scala:21)
2015-08-19T17:49:04.031503+00:00 app[web.1]:    at play.api.db.DefaultDatabase.d
ataSource(Databases.scala:122)
2015-08-19T17:49:04.031464+00:00 app[web.1]:    at com.google.inject.internal.In
itializer$InjectableReference.get(Initializer.java:174)
2015-08-19T17:49:04.031477+00:00 app[web.1]:    at play.core.server.ProdServerSt
art$.start(ProdServerStart.scala:52)
2015-08-19T17:49:04.031505+00:00 app[web.1]:    at play.api.db.DefaultDatabase.g
etConnection(Databases.scala:143)
2015-08-19T17:49:04.031468+00:00 app[web.1]:    at com.google.inject.internal.In
ternalInjectorCreator.build(InternalInjectorCreator.java:110)
2015-08-19T17:49:04.031491+00:00 app[web.1]: Caused by: Configuration error: Con
figuration error[Exception during pool initialization]
2015-08-19T17:49:04.031509+00:00 app[web.1]:    ... 52 more
2015-08-19T17:49:04.031521+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool.create(HikariCPModule.scala:54)
2015-08-19T17:49:04.031471+00:00 app[web.1]:    at com.google.inject.Guice.creat
eInjector(Guice.java:73)
2015-08-19T17:49:04.031494+00:00 app[web.1]:    at play.api.PlayConfig.reportErr
or(Configuration.scala:1048)
2015-08-19T17:49:04.031511+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHi
kariPool.initializeConnections(BaseHikariPool.java:542)
2015-08-19T17:49:04.031523+00:00 app[web.1]: Caused by: java.sql.SQLException: J
DBC4 Connection.isValid() method not supported, connection test query must be co
nfigured
2015-08-19T17:49:04.031470+00:00 app[web.1]:    at com.google.inject.Guice.creat
eInjector(Guice.java:96)
2015-08-19T17:49:04.031493+00:00 app[web.1]:    at play.api.Configuration$.confi
gError(Configuration.scala:178)
2015-08-19T17:49:04.031510+00:00 app[web.1]: Caused by: com.zaxxer.hikari.pool.P
oolInitializationException: Exception during pool initialization
2015-08-19T17:49:04.031522+00:00 app[web.1]:    ... 58 more
2015-08-19T17:49:04.031473+00:00 app[web.1]:    at play.api.inject.guice.GuiceBu
ilder.injector(GuiceInjectorBuilder.scala:126)
2015-08-19T17:49:04.031501+00:00 app[web.1]:    at play.api.db.PooledDatabase.cr
eateDataSource(Databases.scala:199)
2015-08-19T17:49:04.031514+00:00 app[web.1]:    at com.zaxxer.hikari.pool.Hikari
Pool.<init>(HikariPool.java:60)
2015-08-19T17:49:04.031526+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHi
kariPool.initializeConnections(BaseHikariPool.java:540)
2015-08-19T17:49:04.031478+00:00 app[web.1]:    at play.core.server.ProdServerSt
art$.main(ProdServerStart.scala:27)
2015-08-19T17:49:04.031506+00:00 app[web.1]:    at play.api.db.DefaultDatabase.g
etConnection(Databases.scala:139)
2015-08-19T17:49:04.031520+00:00 app[web.1]:    at scala.util.Try$.apply(Try.sca
la:191)
2015-08-19T17:49:04.031475+00:00 app[web.1]:    at play.api.inject.guice.GuiceAp
plicationBuilder.build(GuiceApplicationBuilder.scala:93)
2015-08-19T17:49:04.031502+00:00 app[web.1]:    at play.api.db.DefaultDatabase.d
ataSource$lzycompute(Databases.scala:124)
2015-08-19T17:49:04.031515+00:00 app[web.1]:    at com.zaxxer.hikari.pool.Hikari
Pool.<init>(HikariPool.java:48)
2015-08-19T17:49:04.031527+00:00 app[web.1]:    ... 66 more
2015-08-19T17:49:04.031490+00:00 app[web.1]:    at play.core.server.ProdServerSt
art.main(ProdServerStart.scala)
2015-08-19T17:49:04.031507+00:00 app[web.1]:    at play.api.db.DefaultDBApi$$ano
nfun$connect$1.apply(DefaultDBApi.scala:44)
2015-08-19T17:49:04.031519+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool$$anonfun$1.apply(HikariCPModule.scala:54)
2015-08-19T17:49:04.031459+00:00 app[web.1]:    at com.google.inject.internal.Me
mbersInjectorImpl$1.call(MembersInjectorImpl.java:93)
2015-08-19T17:49:04.031472+00:00 app[web.1]:    at com.google.inject.Guice.creat
eInjector(Guice.java:62)
2015-08-19T17:49:04.031499+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool.create(HikariCPModule.scala:70)
2015-08-19T17:49:04.031513+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHi
kariPool.<init>(BaseHikariPool.java:171)
2015-08-19T17:49:04.031525+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHi
kariPool.addConnection(BaseHikariPool.java:441)
2015-08-19T17:49:04.031516+00:00 app[web.1]:    at com.zaxxer.hikari.HikariDataS
ource.<init>(HikariDataSource.java:80)
2015-08-19T17:49:04.031528+00:00 app[web.1]:
2015-08-19T17:49:04.031791+00:00 app[web.1]:    at play.api.inject.guice.GuiceAp
plicationBuilder.build(GuiceApplicationBuilder.scala:93)
2015-08-19T17:49:04.031517+00:00 app[web.1]:    at play.api.db.HikariCPConnectio
nPool$$anonfun$1.apply(HikariCPModule.scala:58)
2015-08-19T17:49:04.031529+00:00 app[web.1]: 2 errors
2015-08-19T17:49:04.031534+00:00 app[web.1]:    at com.google.inject.internal.In
ternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:176)
2015-08-19T17:49:04.031919+00:00 app[web.1]:    at play.core.server.ProdServerSt
art$.main(ProdServerStart.scala:27)
2015-08-19T17:49:04.031625+00:00 app[web.1]:    at com.google.inject.Guice.creat
eInjector(Guice.java:96)
2015-08-19T17:49:04.031583+00:00 app[web.1]:    at com.google.inject.internal.In
ternalInjectorCreator.build(InternalInjectorCreator.java:110)
2015-08-19T17:49:04.031961+00:00 app[web.1]:    at play.core.server.ProdServerSt
art.main(ProdServerStart.scala)
2015-08-19T17:49:04.031744+00:00 app[web.1]:    at play.api.inject.guice.GuiceBu
ilder.injector(GuiceInjectorBuilder.scala:126)
2015-08-19T17:49:04.031531+00:00 app[web.1]:    at com.google.inject.internal.Er
rors.throwCreationExceptionIfErrorsExist(Errors.java:466)
2015-08-19T17:49:04.031834+00:00 app[web.1]:    at play.api.inject.guice.GuiceAp
plicationLoader.load(GuiceApplicationLoader.scala:21)
2015-08-19T17:49:04.031877+00:00 app[web.1]:    at play.core.server.ProdServerSt
art$.start(ProdServerStart.scala:52)
2015-08-19T17:49:04.031666+00:00 app[web.1]:    at com.google.inject.Guice.creat
eInjector(Guice.java:73)
2015-08-19T17:49:04.031712+00:00 app[web.1]:    at com.google.inject.Guice.creat
eInjector(Guice.java:62)
2015-08-19T17:49:04.879998+00:00 heroku[web.1]: State changed from starting to c
rashed
2015-08-19T17:49:04.868064+00:00 heroku[web.1]: Process exited with status 255
2015-08-19T17:49:05.781059+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=artgallerythomasmurphy.herokuapp.com request_id=e
00bff55-eee8-45cf-af1f-7144741d4a87 fwd="99.59.112.230" dyno= connect= service=
status=503 bytes=

因此。 这是我的application.conf

# This is the main configuration file for the application.
# ~~~~~

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
#
# This must be changed for production, but we recommend not changing it in this file.
#
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
play.crypto.secret = "changeme"

# The application languages
# ~~~~~
play.i18n.langs = [ "en" ]

# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# play.http.router = my.application.Routes

# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.default.driver=org.postgresql.Driver
#db.default.url="jdbc:h2:mem:play"
#db.default.user="Tom"
#db.default.password="160491"
ebean.default = ["model.*"]

# Evolutions
# ~~~~~
# You can disable evolutions if needed
#play.evolutions.enabled=false

# You can disable evolutions for a specific datasource if necessary
# play.evolutions.db.default.enabled=false

我的procfile尝试覆盖的一些变量是否已经注释了错误?

  

web:target / universal / stage / bin / artgallery -Dhttp.port = $ {PORT} -Dplay.evolutions.db.default.autoApply = true -Ddb.default.driver = org.postgresql.Driver -Ddb。 default.url = $ {DATABASE_URL}

到目前为止,我还没有触及heroku上使用h2浏览器在网站上工作的数据库。

1 个答案:

答案 0 :(得分:1)

最有可能的是,你需要更新版本的postgres JDBC驱动程序。这是一个有效的方法:

libraryDependencies ++= Seq(
  jdbc,
  cache,
  "org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
  ws
)

here is a sample app

2.4 migration guide中稍稍提到了这一点。

另一种可能性是你正在使用Slick,它最近有一个支持数据库URL的回归。它将在3.0.3中修复,但在此期间您必须手动将DATABASE_URL转换为JDBC URL。