Running spring tomcat app on heroku - java

I have a spring app that i am running on local tomcat using maven/intellij. I wanted to deploy it on heorko. When i just pushed the app (without any main class or procfile) i got the error that there is no application running.
I then followed this tutorial https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
and added changes to pom.xml, created a Main.java class as suggested and created a procfile on root (where the pom.xml file is) and then i pushed it to heroku. I got the same error that application isn't running.
How can i run a spring tomcat app on heroku.
p.s:
Spring configurations are done using <project_name>Configuration.java class and <project_name>Initializer.java.

Try following the guide for Deploying Spring Boot Applications to Heroku. If you're deploying a WAR file, try following the guide for Deploying WAR Files. Otherwise, you'll need to provide more info about your app.

Related

Interacting with Spring Boot + DynamoDB

I'm struggling to learn how I go about building, packaging, and deploying a Spring REST API locally so that I can interact with it? Ideally, I'd just like to GET and POST data as practice -- specifically integrating with DynamoDB.
I've cloned this DynamoDB project and built it using mvn package so that I have a jar file. I moved the jar file to the webapp directory of Apache and started the server, but I cannot interact with the API in any way. The project is structured as follows:
Once Apache is running with the jar in the webapp directory, I've tried accessing the API at:
http://localhost:8080/
http://localhost:8080/springbootapp (from server.contextPath=/springbootapp in application.properties)
Each gives a 404 error. And yes, DynamoDB is running locally. So what do I need to do differently? How can I deploy and access this API locally?
The project you have cloned is a spring boot project, hence you can use mvn spring-boot:run to run the application locally.You can also run it by running the com.baeldung.Application class as a java application from the IDE. For more details on how to run a spring boot app you can follow this link. Spring boot parent has a dependency on the embedded tomcat, which will run the application.
Additionally if you want to deploy the application as a war the spring boot documentation shows how to do it.

Deploying Java Application to Heroku

So I made a java web application with a normal pom.xml specifying my maven dependencies. Then, I went through the Heroku step by step tutorial on deploying their already-made web app, which did not help in the least bit. Then, I tried deploying the war, with no luck. Then I tried using the Maven plugin. I'm not sure if Heroku or some blog has a step by step guide on deploying to Heroku, but I need one. Can anyone go over what modifications need to be done to the pom.xml and what the procfile should be? And is it also necessary to have a main method in a java class? I thought each servlet was an entry point. My web app works fine on localhost and when I deploy the war on tomcat. It just doesn't work on Heroku no matter what I do to the pom.xml. I included my pom.xml. enter link description here
Run these commands:
$ heroku plugins:install heroku-cli-deploy
$ heroku deploy:war yourapp.war
Then read WAR Deployment on Heroku's Dev Center.

Unable to access application after deploying on Tomcat using maven

I have recently started using Maven build tool for learning purpose.
I've previously made a small web application which was working fine on deploying directly on Tomcat 7.0.67 using Eclipse Indigo.
After I converted my web project into a Maven project and deploying it in the Tomcat server, I am unable to access it. When I check my Manager App tab, I can see my .war is deployed successfully.
Tomcat Manager App
LearningJSPv01..this is the maven project context.
edit: I just observed that while trying to add other web project resource to server, I am not getting the Maven project name

Hosting Grails Application

I have a grails application which is running in http://localhost:8080/appname. I want to Deploy it on www.abc.anything.us. I build a war with production grails.serverURL=www.abc.anything.us. Copied the war to /var/lib/tomcat7/webapps/, but the url not work. Need a document of about publishing grails app to own host.

Spring boot web starter environment detection - embedded or container

I have a Gradle, Spring Boot (web starter) application, that is built to be run either as a standalone application with the embedded container, or deployed to a container as a war.
So I from Eclipse I can run/debug the #SpringBootApplication class, and also deploy the war in Tomcat. All works fine.
Now, for some requirements, I need to know the running environment; standalone or container. Basically, we generate a MANIFEST file to the war, with a Gradle build, and refer to that file for some version/meta information. However, this would be generated only when built from Gradle. Is there any way in code I can differentiate this?

Categories