0

I have create a Spring Boot application successfully and when i execute the application via eclipse run as-> Spring Boot Application the application start successfully and i am able to access the home page via http://local host:8080/

But i start the tomcat independently and deploy the war file using tomcat app manager i am not able to access my application by http://local host:8080/ as this will open the tomcat home page not my applications. Can you please help me on this?

Ashish Chauhan
  • 486
  • 2
  • 8
  • 22

3 Answers3

1

The following steps should work:

  1. Navigate to TOMCAT_HOME/webapps directory.
  2. Rename the ROOT directory.
  3. Create an empty directory ROOT inside TOMCAT_HOME/webapps
  4. Copy the contents of your WAR file to TOMCAT_HOME/webapps/ROOT directory
  5. Restart tomcat and see if http://localhost:8080 works.

However, the right approach would be to create a specific context path for your web application and set is as docBase in your server.xml. Please refer How to set the context path of a web application in Tomcat 7.0 for more information.

  • So Spring Boot app deploy into the tomcat into the same way? – Ashish Chauhan May 25 '17 at 06:03
  • I have provided the packaging type as war. As you suggested I have followed the process to change the root directory. Now i am able to access my application using localhost:8080. But strangly the default index page gets displayed not the one which i have configured. Do you required the directory structure or any specific file to understand this issue? – Ashish Chauhan May 25 '17 at 06:14
  • The problem here is: 1. When i run my application as run as -> spring boot application, it executed successfully and i am able access my home page using localhost:8080. But When i execute it as run as -> Run on server i am not able to access it via localhost:8080. This is happening exactly when i am deploying the war into tomcat and try to access it using locathost:8080 – Ashish Chauhan May 25 '17 at 06:47
  • No for development i am using Spring Tool Suit but i am deploying the generated war into different machine with external tomcat – Ashish Chauhan May 25 '17 at 06:53
  • Let me explain: When i run my application on Spring Tool Suit by clicking Run as -> spring boot application option and once application started successfully and access the URL as localhost:8080, i am able to see my home page. But When i execute within STS but with another option as Run as -> Run on server the home page doesnot get appears by access localhost:8080 so this happening when i create a war file from STS and deploy it into external tomcat – Ashish Chauhan May 25 '17 at 06:59
  • No exceptions occure – Ashish Chauhan May 25 '17 at 07:04
  • i checked it, content is not added into war file – Ashish Chauhan May 25 '17 at 07:10
  • @AshishChauhan In that case, there's a problem with your war file creation. Please refer http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging, create war file correctly and then deploy. –  May 25 '17 at 07:18
0

Please noticed two things:

1 update the deploy type as "war" in pom.xml

2 don't set server.port in application.properties

3 ensure tomcat jar is provided in pom.xml

Please follow this link: https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/

Sheldon Papa
  • 160
  • 1
  • 12
0

In the application.properties file mention below,

server.port = 8080
server.contextPath=/myapp

Deploy myapp.war into server and Hit url in browser:

http://localhost:8080/myapp

Note: if you are using jar run then use below,

java -jar myapp.jar or From Eclispe you can do run as --> Application

RoshanKumar Mutha
  • 2,235
  • 1
  • 12
  • 13