Reputation: 980
I have read many similar questions on stackoverflow and nothing helped me.
I have created a spring boot maven backend project and hosted on heroku.
But, when I try to call from the frontend , it shows an error like this in the browser.
GET https://hoyamu-springboot-backend.herokuapp.com/fetch/bag 503
When I view the log of heroku it shows an error like this. Web process failed to bind to $PORT within 90 seconds of launch
. I did everything and nothing works.
My files are as below,
Heroku Application Log
020-08-08T21:32:21.232432+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-08T21:32:25.103258+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=48348 $JAVA_OPTS -jar target/hoyamu-0.0.1-SNAPSHOT.jar`
2020-08-08T21:32:27.226023+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-08-08T21:32:27.230034+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-08-08T21:32:28.818160+00:00 app[web.1]:
2020-08-08T21:32:28.818210+00:00 app[web.1]: . ____ _ __ _ _
2020-08-08T21:32:28.818211+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2020-08-08T21:32:28.818214+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-08-08T21:32:28.818294+00:00 app[web.1]: \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2020-08-08T21:32:28.818323+00:00 app[web.1]: ' |____| .__|_| |_|_| |_\__, | / / / /
2020-08-08T21:32:28.818414+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-08-08T21:32:28.819695+00:00 app[web.1]: :: Spring Boot :: (v2.2.6.RELEASE)
2020-08-08T21:32:28.819727+00:00 app[web.1]:
2020-08-08T21:32:29.047717+00:00 app[web.1]: 2020-08-08 21:32:29.044 INFO 4 --- [ main] com.udith.hoyamu.HoyamuApplication : Starting HoyamuApplication v0.0.1-SNAPSHOT on 50382c68-eaab-4b3c-ac0c-a881a18e4a0b with PID 4 (/app/target/hoyamu-0.0.1-SNAPSHOT.jar started by u8138 in /app)
2020-08-08T21:32:29.048863+00:00 app[web.1]: 2020-08-08 21:32:29.048 INFO 4 --- [ main] com.udith.hoyamu.HoyamuApplication : No active profile set, falling back to default profiles: default
2020-08-08T21:32:30.083462+00:00 app[web.1]: 2020-08-08 21:32:30.081 INFO 4 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-08-08T21:32:30.224960+00:00 app[web.1]: 2020-08-08 21:32:30.224 INFO 4 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 130ms. Found 18 JPA repository interfaces.
2020-08-08T21:32:31.310818+00:00 app[web.1]: 2020-08-08 21:32:31.310 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 48348 (http)
2020-08-08T21:32:31.327532+00:00 app[web.1]: 2020-08-08 21:32:31.327 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-08-08T21:32:31.327720+00:00 app[web.1]: 2020-08-08 21:32:31.327 INFO 4 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-08-08T21:32:31.405048+00:00 app[web.1]: 2020-08-08 21:32:31.404 INFO 4 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-08-08T21:32:31.405289+00:00 app[web.1]: 2020-08-08 21:32:31.405 INFO 4 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2272 ms
2020-08-08T21:32:31.669531+00:00 app[web.1]: 2020-08-08 21:32:31.669 INFO 4 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-08-08T21:32:31.931057+00:00 app[web.1]: 2020-08-08 21:32:31.930 INFO 4 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-08-08T21:32:32.109028+00:00 app[web.1]: 2020-08-08 21:32:32.108 INFO 4 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-08-08T21:32:32.249430+00:00 app[web.1]: 2020-08-08 21:32:32.249 INFO 4 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-08-08T21:32:33.786599+00:00 app[web.1]: 2020-08-08 21:32:33.786 INFO 4 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-08-08T21:32:33.850851+00:00 app[web.1]: 2020-08-08 21:32:33.850 INFO 4 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2020-08-08T21:33:55.347291+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2020-08-08T21:33:55.368253+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-08T21:33:55.465503+00:00 heroku[web.1]: Process exited with status 137
2020-08-08T21:33:55.499546+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-08T21:50:58.187914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/fetch/bag" host=hoyamu-springboot-backend.herokuapp.com request_id=db721f39-aab3-4a3f-82e9-6495dc6bc7a8 fwd="112.135.40.125" dyno= connect= service= status=503 bytes= protocol=https
Procfile
web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/hoyamu-0.0.1-SNAPSHOT.jar
application.properties
hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
spring.datasource.url=jdbc:mysql://remotemysql.com:3306/MMgqawaw
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show_sql=true
spring.jpa.hibernate.format_sql=true
spring.jpa.show-sql=true
```
What should I do?
Upvotes: 6
Views: 2490
Reputation: 980
After several small surveys, I could find the solution for my issue.
The error Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
can happen due to two reasons.
(replace <BUILT_APP_NAME_HERE> with your app name after deployed)
web: java $JAVA_OPTS -jar -Dserver.port=$PORT target/<BUILT_APP_NAME_HERE>.jar
[or]
When giving * , you don't need to specify the name
web: java $JAVA_OPTS -jar -Dserver.port=$PORT target/*.jar
[or]
web: java $JAVA_OPTS -jar -Dspring.profiles.active=production target/<BUILT_APP_NAME_HERE>.jar --port $PORT
The solution for this is, we have to increase the boot time of the app. you can do this by following this link. ( Sometimes this link gives errors, then try with another browser or with your mobile phone's browser)
https://tools.heroku.support/limits/boot_timeout
However, it is not recommended to increase the boot time more 120secs.
But, in real case, you should find the solution why it takes much time to make the db connection.
Upvotes: 7
Reputation: 116
i was able to run my spring mvc app with this Procfile content:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
this is the deployed app: http://duckingrace.herokuapp.com/web/canvasv1
this is the source code: https://github.com/fajaralmu/java-websocket1
Upvotes: 0