Heroku App (play) working fine locally, then not saving to database on server

扶醉桌前 提交于 2019-12-10 20:51:57

问题


On Heroku using Play V2. Everything works fine when tested locally, but then when I deploy to Heroku and attempt to save to a PostgreSQL database I get the following error.

In my Procfile I have this.

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

Here are my Heroku Error Logs:

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:


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

Seems to indicate that your database is missing some tables. Make sure that your schema is correct. You can get a console to your DB using heroku pg:psql.

A good practice is setting up postgres locally from scratch and make sure that all of the steps to do so are automated by your application or scripts so that it is more difficult to forget things like this.



来源:https://stackoverflow.com/questions/9999107/heroku-app-play-working-fine-locally-then-not-saving-to-database-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!