Running Spring Boot Application on Heroku

Hosting on Heroku – Running Spring Boot Application on Heroku


Running Spring Boot Application on Heroku

Hosting on Heroku

Once you finished watching check out these links:

– 💰

and shhhh follow me on twitter 😎

Other PaaS solutions worth checking out:
– 🍃


– .. I bet Azure has also an equivalent but I haven’t used it 🤷‍♂️

In my channel I discuss things I believe are relevant to either Java & Spring beginners, or advanced developers who want to stay up to date. Feedback is very much welcome!

you search:

Hosting on Heroku

Running Spring Boot Application on Heroku

49 thoughts on “Hosting on Heroku – Running Spring Boot Application on Heroku

  1. anyone here having problems not being able to 'git push heroku master' , getting rejected, because of Java 11 version? even after adding a. 'system.properties' file? "Fatal error compiling: invalid target release: 11 -> [Help 1]""

  2. Please anybody help me I am getting this error but in my local, it's working perfectly

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project spring-boot-WebSocket-chat-app: Fatal error compiling: invalid target release: 11 -> [Help 1]

    [ERROR]

    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

    [ERROR] Re-run Maven using the -X switch to enable full debug logging.

    [ERROR]

  3. Hi, I always put on the application.properties something like this:
    spring.jpa.hibernate.ddl-auto=update
    spring.datasource.url=jdbc:postgres://the_URI?createDatabaseIfNotExist=true&useSSL=false&serverTimezone=UTC
    spring.datasource.username=username_provided_in_credentials
    spring.datasource.password=password_provided_in_Credentials
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL10Dialect
    server.port=8080

    All this is no needed?
    And what about this warning: Please note that these credentials are not permanent.

    If the credentials changes… does heroku conect to de BD either way?
    Thanks!!

  4. everything worked until minute 5:45, this is not working for me 🙁 Im trying to deploy a spring boot app. Log says:

    2020-06-13T19:13:15.903073+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=heroku-boot-final.herokuapp.com request_id=8e03afb9-1da6-49bf-b437-f80322fdeb5d fwd="89.7.163.85" dyno= connect= service= status=503 bytes= protocol=https
    2020-06-13T19:13:16.483998+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=heroku-boot-final.herokuapp.com request_id=85e2cac7-a0e9-467f-b2f4-08bd8d8b09f3 fwd="89.7.163.85" dyno= connect= service= status=503 bytes= protocol=https

  5. If any one of you,are implementing Spring AOP in Heroku,then you need to check if you are using right dependencies,otherwise you may land to Exception Unable to load cache item,which has nothing to do with Cache or JDK,and it is simply a dependecy issue,so far I checked.
    I solved the issue,by performing these steps :-

    STEP1:Add the dependency of aspectjweaver 1.9.5. in pom.xml file.

    STEP2:Add the dependency of aspectjrt 1.9.5. in pom.xml file.

    STEP3:Remove spring-aop dependency in pom.xml file.

    STUDY LINK IS:-

    https://stackoverflow.com/questions/60601994/unexpected-aop-exception-nested-exception-is-java-lang-illegalstateexception-u

    Basically my AOP dependecies were working only in localhost,but heroku did not support spring-aop dependency.So I had to remove spring-aop dependency and instead include aspectjweaver 1.9.5. in pom.xml file and aspectjrt 1.9.5. in pom.xml file

  6. [ERROR] The project com.ecommerce:hmcellcare:0.0.1-SNAPSHOT (/tmp/build_3a8937a52e60b4678d200ce513de67fd/pom.xml) has 1 error

    [ERROR] Child module /tmp/build_3a8937a52e60b4678d200ce513de67fd/backend/pom.xml of /tmp/build_3a8937a52e60b4678d200ce513de67fd/pom.xml does not exist

    Can anyone help with this

  7. I am trying to deploy Spring boot with AOP configuration in heroku.The aspect oriented program works fine in my localhost.Howver it fails in heroku.I am sending the Stack Trace.Could you please provide solution for it?I would appreciate your teaching skills are good.

    E:>heroku logs –tail –app c90boot

    2020-04-15T17:33:41.368242+00:00 app[web.1]:

    2020-04-15T17:33:41.368643+00:00 app[web.1]: 2020-04-15 17:33:41.368 INFO 4 — [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]

    2020-04-15T17:33:41.384935+00:00 app[web.1]: 2020-04-15 17:33:41.384 INFO 4 — [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'

    2020-04-15T17:33:41.502064+00:00 app[web.1]: 2020-04-15 17:33:41.501 WARN 4 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pageController' defined in URL [jar:file:/app/target/c99alpha-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/c99/controller/PageController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item

    2020-04-15T17:33:41.502346+00:00 app[web.1]: 2020-04-15 17:33:41.502 INFO 4 — [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

    2020-04-15T17:33:41.506429+00:00 app[web.1]: 2020-04-15 17:33:41.506 INFO 4 — [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 – Shutdown initiated…

    2020-04-15T17:33:41.533990+00:00 app[web.1]: 2020-04-15 17:33:41.533 INFO 4 — [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 – Shutdown completed.

    2020-04-15T17:33:41.537192+00:00 app[web.1]: 2020-04-15 17:33:41.537 INFO 4 — [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]

    2020-04-15T17:33:41.552882+00:00 app[web.1]: 2020-04-15 17:33:41.552 INFO 4 — [ main] ConditionEvaluationReportLoggingListener :

    2020-04-15T17:33:41.552884+00:00 app[web.1]:

    2020-04-15T17:33:41.552885+00:00 app[web.1]: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

    2020-04-15T17:33:41.556176+00:00 app[web.1]: 2020-04-15 17:33:41.555 ERROR 4 — [ main] o.s.boot.SpringApplication : Application run failed

    2020-04-15T17:33:41.556177+00:00 app[web.1]:

    2020-04-15T17:33:41.556196+00:00 app[web.1]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pageController' defined in URL [jar:file:/app/target/c99alpha-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/c99/controller/PageController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item

    2020-04-15T17:33:41.556197+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556197+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556198+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556199+00:00 app[web.1]: at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556199+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556200+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556200+00:00 app[web.1]: at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556201+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556202+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556202+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]

    2020-04-15T17:33:41.556203+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]

    2020-04-15T17:33:41.556203+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]

    2020-04-15T17:33:41.556204+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]

    2020-04-15T17:33:41.556204+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]

    2020-04-15T17:33:41.556205+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]

    2020-04-15T17:33:41.556205+00:00 app[web.1]: at com.c99.c99alpha.C99alphaApplication.main(C99alphaApplication.java:14) [classes!/:0.0.1-SNAPSHOT]

    2020-04-15T17:33:41.556206+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_242-heroku]

    2020-04-15T17:33:41.556206+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_242-heroku]

    2020-04-15T17:33:41.556206+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_242-heroku]

    2020-04-15T17:33:41.556207+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_242-heroku]

    2020-04-15T17:33:41.556208+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [c99alpha-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]

    2020-04-15T17:33:41.556208+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [c99alpha-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]

    2020-04-15T17:33:41.556208+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [c99alpha-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]

    2020-04-15T17:33:41.556209+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [c99alpha-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]

    2020-04-15T17:33:41.556210+00:00 app[web.1]: Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.IllegalStateException: Unable to load cache item

    2020-04-15T17:33:41.556216+00:00 app[web.1]: at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:214) ~[spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]

    2020-04-15T17:33:41.556216+00:00 app[web.1]: at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) ~[spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]

    2020-04-15T17:33:41.556217+00:00 app[web.1]: at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:471) ~[spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]

    2020-04-15T17:33:41.556217+00:00 app[web.1]: at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:350) ~[spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]

    2020-04-15T17:33:41.556218+00:00 app[web.1]: at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299) ~[spring-aop-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]

    2020-04-15T17:33:41.556218+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556219+00:00 app[web.1]: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1807) ~[spring-beans-5.2.1.RELEASE.jar!/:5.2.1.RELEASE]

    2020-04-15T17:33:41.556219+00:00 app[web.1]: at

  8. hello sir i am try to deploy with free service of heroku but a error shows.. Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, jdbc:postgresql://ec2-52-207-93-32.compute-1.amazonaws.com:5432/d1aiach877p1an?user=zjhvxpvzxnrxte&password=<masked>&sslmode=require

    but i don't have any mysql driver in my pom file or properties file

  9. I have a project for university. A spring boot project with a mongodb databse that acts as a server for an android app. By deploying into heroku with mongodb addon, can I connect the android app to the heroku, and be able to execute the apk on any mobile phone (not more than one at atime) and ask for the same http request as if i was calling my spring application? Also, let's say that i already have a local mongodb instance on my computer which is the one spring app goes fetch data from. When deployed to heroku, does it also notice if i manually edit data/insert data to my local mongodb, either before or after deployment, or do i need to save it through repository code?

  10. It keeps installing jdk 8 at the gitm push heroku matser' even though i specified jdk 11 everywhere, java home, system.properties.txt file, in pom, in project settings, in maven build settings.. and then iit fails with Fatal error compiling: invalid target release: 1.11 -> [Help 1]. Anyone any idea? Literally spent 2 days with this already:D

  11. Hi, great video I also love Heroku, simple and straight forward solution for cloud apps, do you know if the postgresql addon is running on a separate instance of your application (Dynamo)? I just want to know if it is a separate, scaled, replicated service that will hold your data reliably and can I link other apps to that database if I wanted to?. I have done other apps in the past using mongodb with the mLab cloud service but that is not provided by Heroku for my specific app only so I would like to know some of the differences.

Leave a Reply

Your email address will not be published. Required fields are marked *