0

My application only runs on tomcat7-maven-plugin which is present in pom.xml. If I run it on my external tomcat , It gives me error of 404. I tried removing it out of pom.xml, but no use. Any help in this regard is appreciated.

my pom.xml:

<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>com.in28minutes</groupId>
    <artifactId>in28Minutes-springmvc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <verbose>true</verbose>
                        <source>1.7</source>
                        <target>1.7</target>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>
</project>

my web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<display-name>To do List</display-name>

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/todo-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

my dispatcher servelet:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

<context:component-scan base-package="com.in28minutes" />

<mvc:annotation-driven />

<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF/views/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>

pleft
  • 7,567
  • 2
  • 21
  • 45
G.Brown
  • 369
  • 3
  • 16
  • Welcome to SO. Can you please elaborate the steps/actions on: "run it on my external tomcat , It gives me error of 404" ? Do you package your app in a `war` via `mvn clean package`? Log files to check that the application is deployed on tomcat or any other error? There are many details you have to give than just a plain "it doesn't work" – pleft Mar 28 '19 at 10:36
  • 1
    yes, It is war file. I run it through 'tomcat7:run' – G.Brown Mar 28 '19 at 10:42
  • Please show the configuration of the tomcat7-maven-plugin? Are you using a context.xml to configure Tomcat? – Adriaan Koster Mar 28 '19 at 10:44
  • @G.Brown This command uses the `tomcat7-maven-plugin` which you stated that it works – pleft Mar 28 '19 at 10:45
  • 1
    but it doesn't work on my tomcat server – G.Brown Mar 28 '19 at 10:50
  • 1
    It is only working on maven embedded tomcat7, not in external tomcat server – G.Brown Mar 28 '19 at 11:04
  • Show us how you configure it to run on external tomcat – pleft Mar 28 '19 at 11:21
  • 1
    at bottom of eclipse, I configured tomcat 9. Then, right click on project, Run As -> run on server – G.Brown Mar 28 '19 at 11:26
  • So this is mostly an `eclipse` based question. Please update your title and question body to reflect this. – pleft Mar 28 '19 at 11:35
  • See if questions/answers helps https://stackoverflow.com/questions/52875414/tomcat-maven-plugin-for-embedded-tomcat-8-5 – Ori Marko Mar 28 '19 at 15:09

0 Answers0