0

I started a basic web application and using tomcat as server. I worked through it and when tried to run the server, the build is successful and Process finished with exit code 0 and the server is not started. What is the reason the server is not starting ? I have the following web.xml file in the project. If any other file is required to answer the question, please, let me know. I also provided the project structure in the question.

project structure

     <?xml version="1.0" encoding="UTF-8"?>
     <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>basic-web-app</groupId>
<artifactId>basic-web-app</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.0.5.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-servlet-api</artifactId>
        <version>7.0.21</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
        </plugin>
    </plugins>
</build>

riddle_me_this
  • 8,575
  • 10
  • 55
  • 80
Chaklader
  • 159
  • 1
  • 2
  • 16

5 Answers5

3

Run/Debug configurations pop screen

Your Tomcat dependency scope is "Provided"(provided). Make sure you have enabled the "include dependencies with Provided scope" checkbox in the "Run/Debug configurations"

Reference for Scope tag in maven: What is <scope> under <dependency> in pom.xml for?

1

Are you sure you have the right panel active? This is usually what you see when you run a unit test. Your project structure looks fine.

Here's how I'd start it:

  • Go to Run --> Edit Configurations

  • Click the + symbol under Tomcat Server to add one (Local)

  • Type in something in the Name: field to distinguish it ("dev")

enter image description here

  • Uncheck "After launch:" (optional)

  • Click Deployment and click +

enter image description here

  • Choose Artifact

  • Choose the exploded war

  • Click Ok

  • Choose Run and "Run dev"

You should see your Tomcat log populating in the panel at the bottom of the window.

(Note: still evaluating, but it's a great tool!)

riddle_me_this
  • 8,575
  • 10
  • 55
  • 80
1

add the following to your POM : <packaging>war</packaging> IDEA should automatically identify the artifact (your WAR file) to deploy. No need to manually create an artifact.

Run app in tomcat using maven with IntelliJ

jeroen_de_schutter
  • 1,843
  • 1
  • 18
  • 21
soscler
  • 227
  • 4
  • 4
0

check port 8080 is used by any other service. If it is used, kill the other process or use different port by configuring in properties file. mvn tomcat7:run is the command to deploy your application into tomcat. The above configuration need to be done in pom.xml instead of web.xml

0

Assume you have set Tomcat on your IDE correctly. This issue may happen when another process works with the port 8080 that belongs to Tomcat defaultly.

In Windows, run the following command to see what PID uses your port.

netstat -aon | find "8080"

The sample output is:

TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       5048
TCP    [::]:8080              [::]:0                 LISTENING       5048

Then press the ctrl+alt+delete and see the tab details. Kill all the processes with the same PID (5048 in my example) using your port.


Also don't run twice your Tomcat, i.e. don't start it with startup.bat and in your IDE at the same time.

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183