Errors in evolutions on Heroku - postgresql

I tried pushing some evolutions to Heroku:
2012-08-30T10:58:00+00:00 heroku[slugc]: Slug compilation finished
2012-08-30T10:58:02+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=32436 -Xmx384m -Xss512k
-XX:+UseCompressedOops`
2012-08-30T10:58:03+00:00 app[web.1]: Play server process ID is 2
2012-08-30T10:58:05+00:00 app[web.1]: [←[37minfo←[0m] play - database [default] connected at [Database-address]
2012-08-30T10:58:05+00:00 app[web.1]: CREATE TABLE `unapprovedteaminfo` (
---
Copy of 1.sql
---
2012-08-30T10:58:05+00:00 app[web.1]: VALUES (1, 2, 2, '2012-01-01 00:00:00', 'k');
2012-08-30T10:58:05+00:00 app[web.1]: ERROR: syntax error at or near "`"
2012-08-30T10:58:05+00:00 app[web.1]: Position: 14 [ERROR:0, SQLSTATE:42601]
2012-08-30T10:58:05+00:00 app[web.1]: Oops, cannot start the server.
2012-08-30T10:58:05+00:00 app[web.1]: PlayException: Database 'default' is in inconsistent state! [An evolution has not
been applied properly. Please check the problem and resolve it manually before marking it as resolved.]
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.Evolutions$.checkEvolutionsState(Evolutions.scala:155)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.Evolutions$.databaseEvolutions(Evolutions.scala:308)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.Evolutions$.evolutionScript(Evolutions.scala:284)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.s
cala:412)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.s
cala:410)
2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59
)
2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.immutable.List.foreach(List.scala:45)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:410)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59
)
2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.immutable.List.foreach(List.scala:45)
2012-08-30T10:58:05+00:00 app[web.1]: at play.api.Play$.start(Play.scala:60)
2012-08-30T10:58:05+00:00 app[web.1]: at play.core.StaticApplication.<init>(ApplicationProvider.scala:51)
2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$.createServer(NettyServer.scala:132)
2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:153)
2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:152)
2012-08-30T10:58:05+00:00 app[web.1]: at scala.Option.map(Option.scala:133)
2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$.main(NettyServer.scala:152)
2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer.main(NettyServer.scala)
2012-08-30T10:58:06+00:00 heroku[web.1]: Process exited with status 255
2012-08-30T10:58:06+00:00 heroku[web.1]: State changed from starting to crashed
These evolutions would work just fine with H2, I guess there must be some issues with POSTGRESQL syntax. Anyway, the problem I am having now is that, even if I change 1.sql and push the new version on Heroku, the same error will show up in the logs - the copied 1.sql does not change according to the new pushed version.

If you're sending to Heroku 1.sql file generated for H2, there is big chance that they will conflict, instead, set the Heroku's url in application.conf as db.default.url and run it in dev mode on localhost first to generate valid Postres SQL. Also you will need to comment out the db.default.user and db.default.password settings, as Heroku's URL contains this information already.
If you don't know current connection's URL you will find it on:
https://postgres.heroku.com/ -> YourDBs -> db-name -> Connection settings -> JDBC URL
To connect from localhost (or other machine, not in the Heroku's space) you need to add this param to the URL:
&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
Thanks to this approach you can test your application locally with established connection to the remote Heroku's DB, (don't be surprised - that combination will be much slower than working with local app + local DB or Heroku app + Heroku DB) anyway for testing it's better than repeatedly pushing small fixes to the cloud.
Also you'll be able to perform evolutions from localhost - without pushing the code to Heroku, and it's really shorter approach if you have problems in your SQL.
Additionally it's good occasion to turn on SQL logging in local dev mode and hunt for redundant SQL queries, if you'll remove all not necessary queries and will be satisfied on localhost, after deploying to the Heroku, you will be just much more satisfied :)
Reset
If you'll create proper 1.sql file than most probably you'll need to reset your DB containing invalid structure (as I assume that's not a problem yet as you just moving from local to Heroku). First find a name of the DB for the current app (with bash, in app's folder):
heroku pg
And then reset it with (it will destroy all data so consider backup first if you don't want to loose your data!):
heroku pg:reset HEROKU_DATABASE_SOMEBASE

I think you have some problem with the definition in VALUES with the data time field. I posted my working evolutions config setup for play 2.4, Slick 3.0.3 & postgres. I got automatically generated the *.sql files placed in the evolution folder.
Regenerate evolution scripts in play 2
Cheers

Related

heroku java spring mvc hibernate app suddenly not able to access postgres db

I had an heroku app has been running on there for the pass 5 years, and I have not doing any deployment for a while.
Only recently I saw there were two auto update by heroku postgres addon itself
Then from today, I try to go to my app as usual, try to do login, but failed as the app error log is saying not able to connect to postgres DB anymore. Please see these error, and my spring bean setting for DB connection (this setting has been there for 5 years unchanged, suddenly all stop working...)
I am wondering has anyone else encountered this issue recently? is it due to heroku major upgrade?
Please advise an solution if possible
Thanks
=================================================================
I have attached error log here:
2021-02-26T17:18:50.688282+00:00 app[web.1]: Feb 26, 2021 5:18:50 PM org.apache.catalina.core.StandardWrapperValve invoke
2021-02-26T17:18:50.688302+00:00 app[web.1]: SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection] with root cause
2021-02-26T17:18:50.688304+00:00 app[web.1]: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "35.175.150.172", user "hazpvnhqxtodzl", database "d7fhtbev11bt6m", SSL off
2021-02-26T17:18:50.688305+00:00 app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:293)
2021-02-26T17:18:50.688306+00:00 app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
2021-02-26T17:18:50.688307+00:00 app[web.1]: at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
2021-02-26T17:18:50.688307+00:00 app[web.1]: at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
2021-02-26T17:18:50.688308+00:00 app[web.1]: at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
2021-02-26T17:18:50.688308+00:00 app[web.1]: at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
2021-02-26T17:18:50.688308+00:00 app[web.1]: at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:32)
2021-02-26T17:18:50.688309+00:00 app[web.1]: at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
2021-02-26T17:18:50.688310+00:00 app[web.1]: at org.postgresql.Driver.makeConnection(Driver.java:393)
2021-02-26T17:18:50.688311+00:00 app[web.1]: at org.postgresql.Driver.connect(Driver.java:267)
2021-02-26T17:18:50.688311+00:00 app[web.1]: at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
2021-02-26T17:18:50.688312+00:00 app[web.1]: at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
2021-02-26T17:18:50.688312+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
2021-02-26T17:18:50.688313+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
2021-02-26T17:18:50.688313+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
2021-02-26T17:18:50.688314+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
2021-02-26T17:18:50.688316+00:00 app[web.1]: at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:71)
2021-02-26T17:18:50.688316+00:00 app[web.1]: at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
2021-02-26T17:18:50.688317+00:00 app[web.1]: at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
2021-02-26T17:18:50.688317+00:00 app[web.1]: at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
2021-02-26T17:18:50.688318+00:00 app[web.1]: at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
2021-02-26T17:18:50.688318+00:00 app[web.1]: at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
2021-02-26T17:18:50.688318+00:00 app[web.1]: at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:60)
2021-02-26T17:18:50.688319+00:00 app[web.1]: at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)
2021-02-26T17:18:50.688320+00:00 app[web.1]: at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:61)
2021-02-26T17:18:50.688320+00:00 app[web.1]: at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:377)
2021-02-26T17:18:50.688321+00:00 app[web.1]: at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
2021-02-26T17:18:50.688321+00:00 app[web.1]: at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
2021-02-26T17:18:50.688322+00:00 app[web.1]: at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
2021-02-26T17:18:50.688322+00:00 app[web.1]: at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
2021-02-26T17:18:50.688323+00:00 app[web.1]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2021-02-26T17:18:50.688323+00:00 app[web.1]: at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
2021-02-26T17:18:50.688324+00:00 app[web.1]: at com.sun.proxy.$Proxy34.listTillReportHistory(Unknown Source)
2021-02-26T17:18:50.688324+00:00 app[web.1]: at com.lsinternal.restfulservice.ApiTill.reportTillHistory(ApiTill.java:75)
2021-02-26T17:18:50.688325+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2021-02-26T17:18:50.688325+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2021-02-26T17:18:50.688326+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2021-02-26T17:18:50.688326+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:607)
2021-02-26T17:18:50.688333+00:00 app[web.1]: at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
2021-02-26T17:18:50.688335+00:00 app[web.1]: at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
2021-02-26T17:18:50.688336+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
2021-02-26T17:18:50.688337+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)
2021-02-26T17:18:50.688337+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)
2021-02-26T17:18:50.688338+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)
2021-02-26T17:18:50.688338+00:00 app[web.1]: at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)
2021-02-26T17:18:50.688339+00:00 app[web.1]: at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
2021-02-26T17:18:50.688339+00:00 app[web.1]: at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
2021-02-26T17:18:50.688340+00:00 app[web.1]: at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
2021-02-26T17:18:50.688340+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
2021-02-26T17:18:50.688341+00:00 app[web.1]: at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
2021-02-26T17:18:50.688341+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
2021-02-26T17:18:50.688342+00:00 app[web.1]: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
2021-02-26T17:18:50.688342+00:00 app[web.1]: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
2021-02-26T17:18:50.688343+00:00 app[web.1]: at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
Also, the config of my DB connection in spring xml config file:
<bean class="java.net.URI" id="dbUrl">
<constructor-arg value="#{systemEnvironment['DATABASE_URL']}"/>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="#{ 'jdbc:postgresql://' + #dbUrl.getHost() + ':' + #dbUrl.getPort() + #dbUrl.getPath() + '?sslmode=require' }"/>
<property name="username" value="#{ #dbUrl.getUserInfo().split(':')[0] }"/>
<property name="password" value="#{ #dbUrl.getUserInfo().split(':')[1] }"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- change this to 'verify' before running as a production app -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
it is absolutely identical to this tutorial -> https://devcenter.heroku.com/articles/heroku-postgresql#spring-xml
I have been trying to solve the issue in the pass 3 days, really ran out of idea now... please advise if possible
Thanks
Looks like this one:
Seeing "FATAL: no pg_hba.conf entry" errors in Postgres
Issue
I'm seeing "no pg_hba.conf entry for host" errors:
sql_error_code = 28000 FATAL: no pg_hba.conf entry for host "122.180.247.11", user "u3idolso5k2v83", database "dc85788d13v9ej", SSL off
Resolution
"FATAL: no pg_hba.conf entry for host" errors indicate that there was a failed authentication attempt to the database, so the connection couldn't be established. This can happen because of different reasons:
The authentication failed because the user/password credentials were invalid: ((user "xxxx", database "yyyy")). This could happen if you're trying to connect to the database using wrong or revoked credentials. (See also: Why am I seeing connection errors for my Heroku Postgres database from an unexpected IP address?).
The authentication failed because the connection didn't use SSL encryption: (SSL off). All Heroku Postgres production databases require using SSL connections to ensure that communications between applications and the database remain secure. If your client is not using SSL to connect to your database, you would see these errors even if you're using the right credentials to connect to it.
"I think" here SSL OFF is the case/(at least also) true. (Please rather copy&paste logs, than screen-shoting 'em!)
-> (2):
Most clients will connect over SSL by default, but on occasion it is necessary to set the sslmode=require parameter on a Postgres connection. Please add this parameter in code rather than editing the config var directly. Please check you are enforcing use of SSL especially if you are using Java or Node.js clients.
...
It is also important that you use a version of the Postgres JDBC driver verion 9.2 or greater. For example, in Maven add this to your pom.xml:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.1</version>
</dependency>
...
The DATABASE_URL for the Heroku Postgres add-on follows this naming convention:
postgres://<username>:<password>#<host>/<dbname>
However the Postgres JDBC driver uses the following convention:
jdbc:postgresql://<host>:<port>/<dbname>?sslmode=require&user=<username>&password=<password>
If you navigate to your Database Credentials in your panel, Heroku says:
Please note that these credentials are not permanent. Heroku rotates
credentials periodically and updates applications where this database
is attached.
I recommend you check your credentials again, maybe it has changed.

MLab with Heroku: Getting Authentication Failed despite confirming credentials

I deployed a NodeJS app to Heroku and provisioned an instance of MongoDB with MLab. Given that the password for the default database user is unclear (it never asks to set one up), I created a new user with admin privileges called mknerr. I set the MONGOLAB_URI variable like so:
heroku config:set MONGOLAB_URI=mongodb://mknerr:{password}#ds159631.mlab.com:59631/heroku_ws1jw516?authSource=heroku_ws1jw516&w=1
I tried to test the connection locally using mongo ds159631.mlab.com:59631/heroku_ws1jw516 -u mknerr -p {password} but I received the error "-bash: mongo: command not found" despite having already run npm mongodb. Rather than waste time trying to figure out where my mongo installation is, I switched to an instance of Cloud9 I know has mongo installed and ran the same command as above.
It appeared to confirm my credentials were accurate:
MongoDB shell version v3.6.5
connecting to: mongodb://ds159631.mlab.com:59631/heroku_ws1jw5l6
MongoDB server version: 3.6.6
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
rs-ds159631:PRIMARY>
However when I try to load my application, it throws a 503 error. After running heroku logs --tail I see:
2018-07-30T15:04:41.171411+00:00 heroku[web.1]: State changed from up to starting
2018-07-30T15:04:42.187835+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-07-30T15:04:42.324261+00:00 heroku[web.1]: Process exited with status 143
2018-07-30T15:04:43.802715+00:00 heroku[web.1]: Starting process with command `npm start`
2018-07-30T15:04:40.930637+00:00 app[api]: Set MONGOLAB_URI config vars by user {me}
2018-07-30T15:04:46.562425+00:00 app[web.1]:
2018-07-30T15:04:46.562447+00:00 app[web.1]: > todos_api#1.0.0 start /app
2018-07-30T15:04:46.562449+00:00 app[web.1]: > node index.js
2018-07-30T15:04:46.562450+00:00 app[web.1]:
2018-07-30T15:04:47.302228+00:00 app[web.1]: App is running on Port 21448
2018-07-30T15:04:47.339759+00:00 app[web.1]: ERROR connecting to: mongodb://mknerr:{password}#ds159631.mlab.com:59631/heroku_ws1jw516?authsSource=heroku_ws1jw516. MongoError: Authentication failed.
2018-07-30T15:04:47.341632+00:00 app[web.1]: (node:20) UnhandledPromiseRejectionWarning: MongoError: Authentication failed.
2018-07-30T15:04:47.341635+00:00 app[web.1]: at /app/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:598:61
2018-07-30T15:04:47.341637+00:00 app[web.1]: at authenticateStragglers (/app/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:516:16)
2018-07-30T15:04:47.341638+00:00 app[web.1]: at Connection.messageHandler (/app/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:552:5)
2018-07-30T15:04:47.341640+00:00 app[web.1]: at emitMessageHandler (/app/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:309:10)
2018-07-30T15:04:47.341642+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:452:17)
2018-07-30T15:04:47.341644+00:00 app[web.1]: at emitOne (events.js:116:13)
2018-07-30T15:04:47.341646+00:00 app[web.1]: at Socket.emit (events.js:211:7)
2018-07-30T15:04:47.341647+00:00 app[web.1]: at addChunk (_stream_readable.js:263:12)
2018-07-30T15:04:47.341649+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:250:11)
2018-07-30T15:04:47.341650+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:208:10)
2018-07-30T15:04:47.341652+00:00 app[web.1]: at TCP.onread (net.js:597:20)
2018-07-30T15:04:47.341703+00:00 app[web.1]: (node:20) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2018-07-30T15:04:47.341773+00:00 app[web.1]: (node:20) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Why is it failing to connect and throwing an authentication error despite my already having confirmed my credentials are accurate?

Play Framework PostgreSQL db.default.username defaulting to linux username

I keep getting errors like this...
app[web.1]: Configuration error: Configuration error[Cannot connect to database [default]]
app[web.1]: at scala.collection.immutable.List.foreach(List.scala:381)
app[web.1]: Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "lcnjgrwbmbffwv"
app[web.1]: at play.core.StaticApplication.<init>(ApplicationProvider.scala:55)
app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:408)
app[web.1]: at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
app[web.1]: at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
app[web.1]: at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
app[web.1]: at org.postgresql.Driver.makeConnection(Driver.java:410)
app[web.1]: at java.sql.DriverManager.getConnection(DriverManager.java:664)
app[web.1]: at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:363)
app[web.1]: at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240)
app[web.1]: at java.sql.DriverManager.getConnection(DriverManager.java:247)
app[web.1]: at org.postgresql.Driver.connect(Driver.java:280)
app[web.1]: at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
app[web.1]: at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
app[web.1]: at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
app[web.1]: ... 18 more
heroku[web.1]: Process exited with status 255
Not just in Heroku, but when I run my Play app with a user whose name is different than the default user name in the database.
My Play Framework "application.conf" is like this...
db.default.username="nameOfDatabaseUser"
db.default.password="passOfDatabaseUser"
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://urlofdatabase:5432/name_of_database"
Here's the thing. When my terminal user is named "nameOfDatabaseUser", it works. But when my terminal user has a different name, it connects to the database as the name of the current Linux terminal user.
In the above case it appears that Heroku tried to connect as a user lcnjgrwbmbffwv and there was no user lcnjgrwbmbffwv in the database.
How do I specify the default database username so that it doesn't use my terminal username?
The correct key to specify the user is db.default.user, not db.default.username.

Failure when deploying to heroku

I am trying to deploy my Play application to Heroku.
Unfortunatelly, I am getting this issue:
2016-03-06T14:19:45.939373+00:00 heroku[web.1]: State changed from starting to crashed
2016-03-06T14:19:45.918504+00:00 heroku[web.1]: Process exited with status 255
2016-03-06T14:49:45.477844+00:00 heroku[web.1]: State changed from crashed to starting
2016-03-06T14:49:49.783812+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/todolistscala -Dhttp.port=12681`
2016-03-06T14:49:51.431641+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2016-03-06T14:49:51.599056+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2016-03-06T14:49:54.014919+00:00 app[web.1]: [[37minfo[0m] application - Creating Pool for datasource 'default'
2016-03-06T14:49:54.492047+00:00 app[web.1]: [[37minfo[0m] p.a.d.DefaultDBApi - Database [default] connected at jdbc:h2:mem:play
2016-03-06T14:49:57.727928+00:00 app[web.1]: [[33mwarn[0m] application - application.conf # file:/app/target/universal/stage/conf/application.conf: 348: applyEvolutions.default is deprecated, use play.evolutions.db.default.autoApply instead
2016-03-06T14:49:58.246865+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure.
2016-03-06T14:49:58.247105+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret
2016-03-06T14:49:58.258404+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure.
2016-03-06T14:49:58.258431+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret
2016-03-06T14:49:58.258933+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure.
2016-03-06T14:49:58.259062+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret
2016-03-06T14:49:58.293455+00:00 app[web.1]: [[37minfo[0m] application - ApplicationTimer demo: Starting application at 2016-03-06T14:49:58.259Z.
2016-03-06T14:49:58.294643+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure.
2016-03-06T14:49:58.294826+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret
2016-03-06T14:49:58.297164+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure.
2016-03-06T14:49:58.297222+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret
2016-03-06T14:49:58.297271+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure.
2016-03-06T14:49:58.297976+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret
2016-03-06T14:49:58.303328+00:00 app[web.1]: Oops, cannot start the server.
2016-03-06T14:49:58.305408+00:00 app[web.1]: #6pba2k59a: Configuration error
2016-03-06T14:49:58.305742+00:00 app[web.1]: at play.api.libs.crypto.CryptoConfigParser.get$lzycompute(Crypto.scala:498)
2016-03-06T14:49:58.305830+00:00 app[web.1]: at play.api.libs.crypto.CryptoConfigParser.get(Crypto.scala:465)
2016-03-06T14:49:58.305890+00:00 app[web.1]: at play.api.libs.crypto.CryptoConfigParser.get(Crypto.scala:463)
2016-03-06T14:49:58.305953+00:00 app[web.1]: at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
2016-03-06T14:49:58.306059+00:00 app[web.1]: at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
Since there is an error involving the Application Secret, I read this: https://www.playframework.com/documentation/2.5.x/ApplicationSecret. However, I didn't understand how I can send a secret key to the server environment without having it on my local machine.
But anyway, I'm not sure that not having an Application Secret is the actual cause of the issue since the server can not be started(I would assume the server can be started even if I don't have an Application Secret).
What is the cause of this failure?
You should set the application secret as an environment variable on Heroku. That way, it will only be be available to the application environment, and it can easily be changed without re-deploying, if necessary.
You can add a flag to your Procfile:
web: target/universal/stage/bin/todolistscala \
-Dhttp.port=12681 \
-Dplay.crypto.secret=${APPLICATION_SECRET}
The above is for a better visualization, but Procfile won't work with multiple lines per process. It should really look like this:
web: target/universal/stage/bin/todolistscala -Dhttp.port=12681 -Dplay.crypto.secret=${APPLICATION_SECRET}
Then you set the environment variable APPLICATION_SECRET. You can do this either from the Heroku web interface, or using the Heroku toolbelt:
heroku config:set APPLICATION_SECRET="thisisthesecretpleasechangeit" -a your-app-name
Generally, all of your important credentials (database, cache server, API keys) should be stored within the application environment this way.

Errors trying to bootstrap Play! app on Heroku

Cannot for the life of me get Heroku to build a skeleton database for my Play! app using a bootstrap. I've got a Bootstrap job and some YAML to load the object, but I get :-
2011-11-26T15:48:33+00:00 app[web.1]: 15:48:33,451 INFO ~ Starting /app
2011-11-26T15:48:33+00:00 app[web.1]: 15:48:33,454 INFO ~ Module crud is available (/app/modules/crud)
2011-11-26T15:48:33+00:00 app[web.1]: 15:48:33,454 INFO ~ Module secure is available (/app/modules/secure)
2011-11-26T15:48:35+00:00 app[web.1]: 15:48:35,179 INFO ~ Connected to jdbc:postgresql://ec2-107-20-239-110.compute-1.amazonaws.com/qsaljordae
2011-11-26T15:48:35+00:00 app[web.1]: 15:48:35,789 WARN ~ Defaults messsages file missing
2011-11-26T15:48:35+00:00 app[web.1]: 15:48:35,804 INFO ~ Application 'Humbug' is now started !
2011-11-26T15:48:35+00:00 app[web.1]: 15:48:35,860 WARN ~ Precompiled template /conf/initial-data.yml not found, trying to load it dynamically...
2011-11-26T15:48:35+00:00 app[web.1]: 15:48:35,989 DEBUG ~ select nextval ('hibernate_sequence')
2011-11-26T15:48:36+00:00 app[web.1]: 15:48:36,019 WARN ~ SQL Error: 0, SQLState: 42P01
2011-11-26T15:48:36+00:00 app[web.1]: 15:48:36,019 ERROR ~ ERROR: relation "hibernate_sequence" does not exist
2011-11-26T15:48:36+00:00 app[web.1]: 15:48:36,036 ERROR ~
2011-11-26T15:48:36+00:00 app[web.1]:
2011-11-26T15:48:36+00:00 app[web.1]: #68gdihi6a
2011-11-26T15:48:36+00:00 app[web.1]: Error during job execution (Bootstrap)
2011-11-26T15:48:36+00:00 app[web.1]:
2011-11-26T15:48:36+00:00 app[web.1]: Execution exception (In /app/Bootstrap.java around line 12)
2011-11-26T15:48:36+00:00 app[web.1]: RuntimeException occured : Cannot load fixture initial-data.yml: org.hibernate.exception.SQLGrammarException: could not get next sequence value
What is the problem with the hibernate_sequence table? That's not a table/object I created.
This bootstrap process worked fine in Dev on my local machine.
And the answer was to set jpa=ddl in the config, despite the warning not to do so in production....
# Specify the ddl generation pattern to use. Set to none to disable it
# (default to update in DEV mode, and none in PROD mode):
jpa.ddl=update