Aws Spring boot application view issue with jar and rest service issue with war - spring-boot

I would like to host one application on AWS elastic beanstalk(java). The application has one view and one rest service. First I uploaded the jar file and tried accessing, the path to view was giving me whitelabel error on AWS but it is working fine locally. Also, am able to access the rest service with jar.
After surfing the net, I created a war and uploaded on AWS(tomcat). Now, the view is working fine but I notice the path of rest service is returning 404. Can someone suggest what should I check or do?

Related

Springboot actuator endpoints are not working after deploying app to pcf

I have a springboot app which has 3 actuators enabled as below out of which 3rd one is custom,
application.properties code snippet
management.endpoints.web.exposure.include=health,refresh,customEndpoint
the endpoints when hit from local are working correctly. For example:-
http://localhost:8081/MyAppName/system/health gives below expected details:-
but when we hit the same endpoint(with pcf app route mapped) which is my_route_url/MyAppName/system/health, after deploying the app to pcf, it gives below 404 error:-
404 Not Found: Requested route ('my_route_url') does not exist.
Tried redeploying the app to pcf but that did not help.
Tried looking for solutions in other questions posted here but they are not matching scenario.
it's working in a different pcf foundation though.

SpringBoot Rest API: Works as Java Application, fails when deployed on tomcat

I have a Springboot project and it has a api which I can invoke from postman.
When I run the application using Main Class I'm able to hit the endpoint and get response.
But if I deploy it on tomcat using war of project the same endpoint says 404!
What am I missing?
There can be multiple possibilities
You didn't extended your application class to SpringBootServletInitializer. In this case, spring boot application will not be deployed to tomcat. To fix this add "extends SpringBootServletInitializer" to your main application class
You are hitting wrong url. Make sure you append your aplication name to url. Example - if http://localhost:8080/data works in your local, and your application name is app, you have to hit http://{{serverip:port}}/app/data when deployed
There is something wrong in application properties like DB configured is local and not accessible from tomcat etc. To check such issues, check your tomcat log file (/{{tomcat dir}}/logs/catalina.out

spring boot application war deployment in AWS Beanstalk

My colleague and me developed simple spring boot application and deployed (war file) in AWS Beanstalk. It is not worked properly.My first
page(loginpage.jsp-Get mapping) loaded perfectly in AWS. After submitting credentials my second page(Mainpage.jsp - Post mapping)
does not loaded. It shows internal server error=500 only. But we deployed on Tomcat server(local) all pages (Request and Response) loaded perfectly.
we did not added any cloud dependency in Pom.xml. Please help us...
This is our
Error message.
This is our
Pom.xml.

How to deploy html from tomcat server with Springboot

So, the answer is probably super easy, but I just can't seem to figure it out.
I have set up a REST webservice, according to this tutorial: https://spring.io/guides/gs/rest-service/ and have set up the Requestmapping and everything using postman, and that end is working like I intended to.
I am setting up my site locally, but when I try to send a get request with jquery, I am receiving the following error: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
So I have understood that the problem is that I am trying to run my html from file:// and that the solution is to run it from localhost on the tomcat server and found this answer in another topic: Deploying just HTML, CSS webpage to Tomcat
However, I cannot find such a webapps folder, and I am assuming it is because my tomcat server is deployed using maven and springboot. So how do I deploy my html/js on the tomcat server when it is deployed this way?
I am working on a mac and with IntelliJ.
In your spring boot application you can put your index.html file in src/main/resources/static directory and it will be served by the application.
Also you may try to configure CORS in spring boot, see this answer for links.
If you are deploying normal web applications like jee apps you do it by placing your war file in webapps folder. The web apps folder is inside your tomcat
But for for intellij-idea go through this, it should work:
Where is my app placed when deploying to Tomcat?

Bluemix "forbidden" error on JSP pages

I deployed my java application on Bluemix. It's a Spring MVC application with some REST controller to expose web services and some jsp page to create a admin panel.
The JSP pages are in the root of web application (not in WEB-INF directory). If I run the application in local on my tomcat server, everything works, the web services and the JSP, but if I deploy on Bluemix i have this error:
Error 403: SRVE0190E: File not found: /admin/index.jsp
It's a strange error because it says "File not found", but it's not a 404 error, but a 403 (Forbidden), so I think it could be some kind of configuration problem...
Thanks
If your application runs on tomcat locally, then you can try using the tomcat buildpack:
cf push <appname> -b java_buildpack -p path/to/file.war
your problem seems related to your application context root, probably the server.xml resulting after application uploading and staging is not enough to manage it.
Generally speaking before submitting an application on Bluemix it should be better trying to deploy it to a local Liberty server first. If you are able run this application locally on your liberty server, package up the server, and then push the package using the related option from cf cli.
Follow this link https://www.ng.bluemix.net/docs/starters/liberty/index.html
to have a complete reference about java liberty runtime on Bluemix and about its options

Resources