Running Heroku Spring MVC App locally - spring

Spring Newbie
Hi guys, I was trying out heroku to develop a Spring MVC application. I used its 'Spring MVC and Tomcat Application' template to create a Spring App. Is there a way I can deploy it on my local tomcat server for testing ?
After I created a project, with the default configuration, I was not able to see the 'Run On Server' when I tried to run my project. I was not able to see the project in the 'available resources' section of the server too.
I followed this blog to create a self contained web application, but it started thorwing these errors after I run its Main :
Problem accessing /. Reason:
No org.apache.tomcat.InstanceManager set in ServletContext
Isnt there an easier method to run the app locally, without running it as a self hosted web application ? (Not even sure if it was the right thing to do to run it locally.)

This did it :
$mvn clean install
Then run it with:
$java -jar target/dependency/webapp-runner.jar target/*.war

Related

can you help me fix my STS? as it is not working

I am new to STS and trying to run my first project in it. But it is not showing me run on server option. I have tried "clean install" but still, it is not working. When I checked targeted runtimes it is not showing any server in it. Kindly help me to resolve this issue.
My recommendations for getting started with the Spring Tools 4 for Eclipse are:
start the IDE with an empty workspace
create a new Spring Boot project using the wizard "Import Spring Getting Started Content" to import some getting started guides, for example the Rest Service example
if you decide to create an empty new Spring project, use the wizard "Spring Starter Project" - it is the direct integration for https://start.spring.io - and go from there
All those options get you started with a Spring Boot project which doesn't need a separate server to run on. Spring Boot comes with am embedded server component, so you can just start the Spring Boot application as a regular Java app. No need to install a local server or use the "Run on Server" option in the IDE.

Running Spring boot application in IntelliJ gives white label error

I am trying to run Spring boot web application in IntelliJ which gives me whitelabel error. However, I am able to run the application with eclipse and also external tomcat server.
I have the context mapping available where it is returned from the application but webpage always shows WhiteLabel Error 404.
Please suggest how does the same application works in eclipse and external tomcat but not with IntelliJ.
I am using IntelliJ community edition v 2020.2.3
web pages are available in webapp folder.
First download xammp server to your machine. Then run your spring boot application. I used this method to run my spring boot application. But keep in mind that IntelliJ community doesn't directly support to spring-boot. You have to use IntelliJ ultimate for that.

Can I configure SpringBoot app to run on a tomcat that is added to eclipse IDE in its servers tab?

I am trying to create a spring boot web app. But i dont want to create a jar out of it.
I want to run the web app directly from eclipse on to the tomcat that is added to eclipse via servers tab.
Is it possible? How to achieve it?

Netbeans 8.2. Maven webapplication won't run on Tomcat but will on Glasfish server

I am developing a simple restful server and want to deploy it on a Tomcat server. When I deploy the project it won't run and gives me the message: http 404, The requested resource is not available.
The project is a default, newly created Maven project and when I select Glasfish it runs fine. Can anyone give help me to find out what I am doing wrong?
I found the problem myself. For anyone struggling. Java Jax-RS doesn't run default on Tomcat. You need Tomcat EE or add EE to Tomcat.

Moving Spring boot web application in tomcat 8

I made a little web app with Spring Boot with web MVC, it is working fine if I run it by deploying the war or if I run it directly from STS. The problem is that my application is always run with his appname as context app (something like "localhost:8080/appname/") and I can't change it. I tried to write a web.xml with dispater-config.xml but, even if the server recognize it, the path is not changed. I tried to write the method in the SpringBootServletInitializer and setting the path, but it is not working too. I also tried to add a META-INF/context.xml in the webapp folder trought STS (project->src->webapp->META-INF->context.xml) but it's not working too. I am just going crazy with, what should i do to change the app's context path? Thanks
EDIT: I would mount my app in the root context of tomcat
It's built in, in eclipse (STS). I suggest using a stand alone tomcat and not the integrated eclipse tomcat and deploy the war on your stand alone tomcat
Add the context path as a parameter to your #RequestMapping annotation, like this: #RequestMapping("/helloworld")

Resources