Deploying Spring boot app to digital ocean - spring-boot

I am trying to deploy spring boot app written using jhipster to digital ocean. I user tomcat manager to deploy. The deployment went fine and I am able to access the html pages, but my rest apis are not accessible. I get 404 when I try to access any rest api.
I also don't know where my application startup logs are going (they are not there in localhost-access.$date.log) file under logs directory. AM I missing any configuration?
Any help or suggestion is appreciated.

The issue was with my droplet's limited RAM and memory. I noticed the JVM was not running. When I increased size of RAM it started working just fine.

Related

Unable to access Actuator when a springboot application is running via a fat jar file on an application server

I am a little out of my league on this one as I am still getting familiar with everything Springboot. Onto my problem...
I am unable to access actuator for an application that is running in a fat jar file on an application server. All works great when I run the application locally through Eclipse as I am perfectly able to access a couple of the endpoints (health, logfile) via a browser and Postman.
However, when I attempt to access those same endpoints (via curl, a browser or Postman) using the application server's url, I get a 404. I am able to access other custom written apis within the application with no issue, just not actuator apis.
I know I am missing something very obvious, but cannot figure out what that is.
Good - http://localhost:9091/actuator/health --> from a browser or Postman
Not good - http://my-app-testserver-01:9090/actuator/health or curl localhost:9090/actuator/healthand both yield the below error. NOTE that the curl is performed on the application server.
"timestamp":"2022-06-30T20:57:12.191+00:00","status":404,"error":"Not Found","path":"/actuator/health"
What else? Oh yeah, below is a snippet from my yml file pertaining to actuator and I believe that is ok.
Any insight on this is greatly appreciated. Thank you.
management:
server:
port: 9090
endpoints:
web:
exposure:
include: "health,info,logfile" ```
This is all set now. I was setting up the application on a new server and had to have the ports opened up for me. Once that was done I was able to access the Actuator apis with no issues.

Azure app service returning 404 for Spring boot Java 8 based war

I am trying to deploy a Springboot based war file on Azure app services and I can see server started in logs but its returning 404 when I try to access website.
Here's what my logs looks like:-
Start up command from app service logs:-
'2022-05-09T22:17:09.766Z INFO - Starting container for site
2022-05-09T22:17:09.766Z INFO - docker run -d -p 80:80 --name testing3_0_315c5bf8 -e WEBSITE_SITE_NAME=testing3 -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=testing3.azurewebsites.net -e WEBSITE_INSTANCE_ID=192ae7e12efabd86b8f1992c5d0955e31956c2538c35216038ae1c4c72bce58c -e HTTP_LOGGING_ENABLED=1 -e JAVA_TOOL_OPTIONS=-javaagent:/agents/java/applicationinsights-agent-codeless.jar mcr.microsoft.com/azure-app-service/java:8-jre8_191030025800'
Successful starting logs:-
'2022-05-09 22:19:49.960 INFO 123 --- [main] com.case.client : Started testing in 111.231 seconds (JVM running for 138.403)'
I tried to look for it on Stackoverflow and people suggested below things and I tried all of them but nothing is working:
Changing Always On flag to Yes.
Add PORT mapping in config but it didnt help.
Restart app couple of times.
Looks like my request is not reaching my app at all.
Does anyone know what am I doing wrong here?
I had the same issue with Spring Boot 3. This stack overflow article is 8 month old, because of that it's maybe different problem.
I contacted the Microsoft Support because locally my app runs without any problem. Only in combination with an Azure Web App Service, the application always returns HTTP 404. I deployed the application with the IntelliJ Azure plugin, with maven plugin and with Azure pipeline. No matter which way, the server always returns HTTP 404.
We can see the incoming http request in the Azure Web Service logs, but it is not delivered to the deployed application. But the Spring Boot application is up and running. I downgraded to Spring Boot 2.7.7 and the app runs without any problem on Azure App Service.
The Microsoft Support confirmed the problem with Spring Boot 3 and Azure App Service in combination with codeless Application Insights. The issue will be fixed with the next platform update mid Feb 2023.
The support has provided a workaround: manually install the Application Insights SDK (but we didn't test this yet)
There is no official article for this issue. I thought this might be a good place to announce this problem to help other developers.

How can I deploy a Spring Boot REST API to BanaHost cPanel?

I created a full stack application (Angular front end, java spring boot back end, mysql database), and I was able to upload successfully both the angular files and mysql into BanaHost cPanel, however I have not found useful information on how to upload spring boot REST API, as a consequence only the front end is working. How can I deploy this REST API on cpanel?
Spring Boot Applications can't just upload and deploy if you're utilizing a cPanel Web hosting (shared) plan, like you deployed the Angular Application by uploading.
For spring boot you must do it yourself, a Virtual Private Server or Dedicated Server will unlock the site hosting restriction. If you are not much familiar with the Linux command line, you can use a Window VPS instead. Providers like, Digital Ocean, Linode, and Oracle Cloud all provide free trials.
And also, there are platforms, such as Heroku (Platform as a Service(PaSS)), where you can deploy your app without the need for a VPS. You can refer their documentation regarding this:
https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku

How to run a Spring Boot Application in a real online website instead of localhost:8080

I've created an application with the spring boot framework.
Everything runs fine on the localhost:8080.
Now I want to be able to run the application from my website.
So people can log in to the app and use the application from anywhere over the internet.
What should I do to manage this?

Deploy my spring boot application into google cloud computer engine

I got a query to ask you all. I am looking for guides that help me deploy my spring boot application on google cloud computer engine, I type in my instance IP address when I test my spring boot application I unable to access it in REST API.
May I know do you have any guides or steps for me to follow to deploy successfully in google cloud computing engine. Why do I need to deploy in computer engine is because I deployed my angular at it and I deploy it both it seems that my angular project being replaced by my spring boot application.
Codelabs GCP / Spring series has deployment tutorials:
https://codelabs.developers.google.com/spring/
GCP has some "Getting Started" tutorials you can use here:
https://cloud.google.com/java/docs/
where the specific one for deploying a java app to GCE is here:
https://cloud.google.com/java/docs/tutorials/bookshelf-on-compute-engine
But the basic steps are as follows:
Write your Spring app
Build your Spring app
Run / test your jar locally
Push your jar to a location in Storage
Create a startup script for your GCE instance
Create a new GCE VM which uses your startup script using Console, Deployment API, or gcloud tool
After that, you need to ensure you have the proper network rules in place to be able to access your API publicly. If you do not wish to learn how to use GCE, I would suggest you look into using App Engine instead because then you do not need to learn how to deploy and instead can concentrate on your api. Here is a guide to do that

Resources