Spring Boot app not running properly on Azure - java

I have a spring boot application, built to a war file. The code is here. The application works properly when running locally in ./gradlew bootrun, and my REST endpoints are responsive.
I set up FTP credentials on my azure site (Windows resource), and I've successfully uploaded the war file via the deploywar endpoint, as described here.
When I FTP in to the site, I see the war file exploded in to /site/wwwroot/webapps/ROOT/. However, it's unclear to me how to access the site.
THe main URL is https://springboottest01.azurewebsites.net/, which still is serving the hostingstart.html. If I go to https://springboottest01.azurewebsites.net/webapps/ROOT/, I pull down my webapp's index.html, and a few JS files. However, the REST API call that it tries to make, /students/list, fails to run (404 error), which makes me think that the spring boot backend isn't actually running.
How do I diagnose this? What do I need to do to get this to work?
I also tried setting up a Linux resource (Tomcat 8.5) and deploying the webapp to that site. When I do that, I get the same problems there (in this case, the webapp is available at the root URL of that resource, but the REST endpoint that it tries to call fails). https://springboottest02.azurewebsites.net/

Related

How to use application name in URL after port (like we do in tomcat deployed application) for calling rest web service in GWT application?

I have a GWT application deployed and which i am running via calling a run configuration (Run -> Run Configurations -> Web Application -> create a new configuration -> Run). Now, this process typically deploys project on following URL: http://127.0.0.1:49240/GWTSample.jsp
But now, I have integrated rest web service in my project, and which has one URI for rest call as following: /GWTSample/rest/hello.
But when I modify actual URL to this: http://127.0.0.1:49240/GWTSample/rest/hello this URL does not work.
As a long solution, I have to compile my project and deploy it on Tomcat as following URL: http://localhost:8080/GWTSample/rest/hello, which takes more than 10 minutes every time.
So how can i make rest calls on my project on http://127.0.0.1:49240/GWTSample.jsp ?
If your hostpage and your REST servlet are in the same web application then the URLs are constant relative to the web application context.
Apparently, your development mode server uses root context "/". So your development URL paths are "/GWTSample.jsp" and "/rest/hello". But your external Tomcat uses "GWTSample" as context which leads to URL paths of "/GWTSample/GWTSample.jsp" for the hostpage and "/GWTSample/rest/hello" for your REST service.
To call your REST service from your GWT app you can either use relative URLs or you determine the context path at runtime on server side (see ServletContext.getContextPath()) and pass this path to your GWT application (e.g. by integrating it into the hostpage).
The context itself is a deployment detail. Of course, you can configure your Tomcat to use root context, too. But it would be better for your application to not rely on that.

How to deploy webService and get access to wsdl?

I have got a webService without ui. It simple jax-ws app that will allow to manage users via soap requests. I tried to deploy it on websphere. It was deployed, But! my app doesn't appear in Service Providers and i can't get access to wsdl file via url that i pass in wsdlsoap:aderess location. It haven't got any servlets and other stuff. I create my app using template that deploy with success, it appear in Service Providers. I research all internet, but idk what go wrong.
P.S: Template project was eclipse project. I just add maven and has no idea why it wouldn't work.
The fact that your web service hasn't appeared in the Service Providers section means you've deployed it the wrong way.
Check whether you've selected the "Deploy web-services" option during deployment.
You probably got an issue in your trace.log file which possibly references to the ffdc, check it to investigate the problem.
You also haven't mentioned if you using servlet or EJB-based web services.

How to deploy REST web service to Heroku?

I am trying to deploy a simple java rest service using webapp-runner in heroku, i follow the instructions in documentation and everything perfect, i run my app and is working cause i can see my html welcom page, the problem is that i cant access to my rest resources with the path i provided even in a local deploy http://localhost:8282 this is the path when i open my app, http://localhost:8282/wr/test and this should show a simple get method, but doesn't work neither local with webapp-runner nor remote in heroku, this is the link https://appbergas.herokuapp.com/ , what am i doing wrong? which should be the complete uri i thought https://appbergas.herokuapp.com/wr/test
im using javax ws rs,also when i deploy it in glassfish everything goes great.

Deploy Angular 5 and spring boot applications on same tomcat at different ports

I am developing a small project where I have Springboot java application and
Anagular 5 application. I want to deploy them on one tomcat. running each on diffrent ports.
Application Flow should be like this:
1) Some external service calls Java application with some headers. Springboot java application should read the headers put them in cookie and forward the request to Angular application.
2)Angular application reads the headers from the cookie and communicates to another application(Hosted somewhere else) with API calls.
What I tried:
I am able to deploy Spring boot application on tomcat.
For angular deployment I am copy pasting the dist folder into webapp.
What is question about: I wanted them to run at a time on tomcat on defferent ports so.
external application --calls-> java application(say running on localhost:8080)-----redirect from localhost:8080 to ----> Angular application(say running on localhost:8081).
in moment your are delegating servlet container to a provided one, all spring properties concerning an "embedded" container will be simply ignored. This is the case of server.port property.
Maybe it's a client/company constraint BUT using Spring Boot project this way makes you loose big part of its benefits: Raising serverless apps ready to be horizontaly scaled :(
Spring Boot keeps the possibility to let your static resources in the apps whitout loosing the ability to run the embedded container; by building an executable war.
Tip: To do that, just change the packaging from .jar to .war.
Hope was helpful :)

"CGI application encountered an error" in Java web app deployed on an Azure App Service

I have a Java web application that is deployed on Azure. The app has several endpoints, one of which accepts a POST request together with an image as input. This endpoint works perfectly when I run it on localhost, however it gives me the following error when deployed on Azure:
The specified CGI application encountered an error and the server
terminated the process.
The HTTP status code for this response is 502 Bad Gateway.
The logs under /LogFiles/ do not tell me anything about the cause of the problem. I see some exceptions, but my application handles with ease using a mechanism that catches any uncaught exceptions before they can crash the application, and sends the exception message back as a response, in a JSON format. So the fact that the response I'm getting being something entirely different than the ones my exception handler generates is also really confusing.
Edit: I'm deploying my app using a separate Bitbucket repo, which only includes webapps/ROOT.war in it. When I update the ROOT.war file with my new build, Jetty automatically deploys the new build. I'm not using a web.config file, and I'm not sure where I would put it in my context (a Java web app deployed as a .war file) as the tutorials I've seen do not mention this.
Also, one thing I've noticed when I connect to my server via FTP is that ROOT.war file lies under wwwroot/webapps/ directory, but I can't see the actual deployed app, which, I believe, should reside in wwwroot/webapps/ROOT/.

Categories