Heroku App(播放)在本地工作正常,然后不保存到服务器上的数据库

时间:2012-04-03 18:23:02

标签: java heroku playframework ebean

使用Play V2在Heroku上。在本地测试时一切正常,但是当我部署到Heroku并尝试保存到PostgreSQL数据库时,我收到以下错误。

在我的Procfile中我有这个。

web: target/start -Dhttp.port=${PORT} -DapplyEvolutions.default=true -Ddb.default.url=${DATABASE_URL} -Ddb.default.driver=org.postgresql.Driver

以下是我的Heroku错误日志:

2012-04-03T18:16:05+00:00 app[web.1]: play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[PersistenceException: Error getting sequence nextval]]
2012-04-03T18:16:05+00:00 app[web.1]: ! @6a0gdoh95 - Internal server error, for request [POST /users] ->
2012-04-03T18:16:05+00:00 app[web.1]:   at play.core.ActionInvoker$$anonfun$receive$1.a

2012-04-03T18:16:05+00:00 app[web.1]: [error] application - 
2012-04-03T18:16:05+00:00 app[web.1]: 
2012-04-03T18:16:05+00:00 app[web.1]: 
2012-04-03T18:16:05+00:00 app[web.1]:   at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:63) [play_2.9.1-2.0.jar:2.0]
2012-04-03T18:16:05+00:00 app[web.1]:   at play.core.ActionInvoker.apply(Invoker.scala:61) [play_2.9.1-2.0.jar:2.0]
2012-04-03T18:16:05+00:00 app[web.1]:   at com.avaje.ebean.config.dbplatform.SequenceIdGenerator.loadMoreIds(SequenceIdGenerator.java:163) ~[ebean-2.7.3.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at com.avaje.ebeaninternal.server.deploy.BeanDescriptor.nextId(BeanDescriptor.java:1218) ~[ebean-2.7.3.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at com.avaje.ebean.config.dbplatform.SequenceIdGenerator.getMoreIds(SequenceIdGenerator.java:213) ~[ebean-2.7.3.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at akka.actor.ActorCell.invoke(ActorCell.scala:617) [akka-actor-2.0.jar:2.0]
2012-04-03T18:16:05+00:00 app[web.1]:   at com.avaje.ebeaninternal.server.persist.DefaultPersister.setIdGenValue(DefaultPersister.java:1304) ~[ebean-2.7.3.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:179) [akka-actor-2.0.jar:2.0]
2012-04-03T18:16:05+00:00 app[web.1]:   at akka.actor.Actor$class.apply(Actor.scala:290) [akka-actor-2.0.jar:2.0]
2012-04-03T18:16:05+00:00 app[web.1]:   at com.avaje.ebean.config.dbplatform.SequenceIdGenerator.nextId(SequenceIdGenerator.java:118) ~[ebean-2.7.3.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]: Caused by: javax.persistence.PersistenceException: Error getting sequence nextval
2012-04-03T18:16:05+00:00 app[web.1]:   at com.avaje.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:403) ~[ebean-2.7.3.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1810) ~[postgresql-8.4-702.jdbc4.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271) ~[postgresql-8.4-702.jdbc4.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2077) ~[postgresql-8.4-702.jdbc4.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386) ~[postgresql-8.4-702.jdbc4.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]: Caused by: org.postgresql.util.PSQLException: ERROR: relation "user_seq" does not exist
2012-04-03T18:16:05+00:00 app[web.1]:   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) ~[postgresql-8.4-702.jdbc4.jar:na]
2012-04-03T18:16:05+00:00 app[web.1]:   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:498) ~[postgresql-8.4-702.jdbc4.jar:na]

1 个答案:

答案 0 :(得分:2)

2012-04-03T18:16:05+00:00 app[web.1]: Caused by: org.postgresql.util.PSQLException: ERROR: relation "user_seq" does not exist

似乎表明您的数据库缺少某些表。确保您的架构正确无误。您可以使用heroku pg:psql获取数据库的控制台。

一个好的做法是从头开始在本地设置postgres,并确保所有执行此操作的步骤都是由您的应用程序或脚本自动完成的,这样就更难忘记这样的事情了。