0

I was trying to deploy spring boot micro-service on the tomcat server but was unable to get any response. The url was showing 404 error then I decided to go from very basic so I created a simple spring boot project with Spring Boot Initializer. There I choose

  • war as packaging.
  • java version 16 (as I only have this on my machine).
  • Added Spring Web dependency.

With this setting spring initializer automatically added necessary stuff like war packaging, tomcat dependency, spring web dependency and also created ServletInitializer class for me. After that I opened the downloading project in netbeans 12 and made just a few changes i.e.

  • Added main class in the pom.xml file with <start-class> tag and annotated main class with @RestController and exposed 1 endpoint which return simple string.
  • Then from the project's main folder I ran the command mvn package also tried mvn clean install as deployment with the 1st command was unsuccessful.

Here are my configuration
Environment Variables:
System Variables

  • CATALINA_HOME: D:\Inzimam Tariq\apache-tomcat-10.0.10.
  • JAVA_HOME: C:\Program Files\Java\jdk-16.0.2
  • Relevent values in Path Variable: C:\Program Files\Common Files\Oracle\Java\javapath, D:\Inzimam Tariq\apache-maven-3.8.2\bin, and C:\Program Files\Java\jdk-16.0.2\bin.

User Variable

  • MAVEN_HOME: D:\Inzimam Tariq\apache-maven-3.8.2\bin.

I'm using windows 10 64-bit. Tomcat manager shows the app as deployed but when I click on that it shows 404. My JDK folder does not show JRE folder so I searched over internet and found that Java does not include JRE now. I also tried to rename my war file to the project name as some articles suggested that i.e. abc.war from abc-0.0.1-SNAPSHOT but still error is the same.

Please can someone point me to the right direction? Regards

Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69

1 Answers1

-1

After Deploying your project war file in Tomcat, try to make the following changes in your POM.xml file. Then restart your tomcat. Probably it will work.

 <dependency>
            <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>    
                        <exclusions>
                        <exclusion>
                        <groupId>com.zaxxer</groupId>
                        <artifactId>HikariCP</artifactId>
                        </exclusion>
 </exclusions>
                </dependency>

                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-web</artifactId>         
                        <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                     <artifactId>spring-boot-starter-tomcat</artifactId>
                 </exclusion>
             </exclusions>
                </dependency>
<dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <scope>test</scope>
                        <exclusions>
                                <exclusion>
                                        <groupId>org.junit.vintage</groupId>
                                        <artifactId>junit-vintage-engine</artifactId>
                                </exclusion>
                        </exclusions>
                </dependency>
An student
  • 392
  • 1
  • 6
  • 16