Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

    I found a lot of forums telling about the error I typed in subject and I did try every suggestion without success. I did include the servlet-api.jar from Tomcat7 lib folder to Java Build Path
    In Eclipse I have:
    src/main/java/tutorial/mvc/TestController.java
    src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
    src/main/webapp/WEB-INF/web.xml
    src/main/webapp/WEB-INF/jsp/view.jsp

    1 - TestController.java
    package tutorial.mvc;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    @Controller
    public class TestController {
    	@RequestMapping("/test")
    	public String test(){
    		return "view";
    	}
     
    }
     
    2 - mvc-dispatcher-servlet.xml
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:mvc="http://www.springframework.org/schema/mvc" 
    	xmlns:context="http://www.springframework.org/schema/context"
    	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.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd">
    	<context:component-scan base-package="tutorial.mvc" />
    	<mvc:annotation-driven />
     
    	<bean id="jspViewResolver"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    /web.xml/web.xml
    		<property name="prefix" value="/WEB-INF/jsp/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
     
    </beans>
     
    3 - 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>Spring MVC Application</display-name>
    <servlet>
    	<servlet-name>mvc-dispatcher</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>mvc-dispatcher</servlet-name>
    	<url-pattern>/</url-pattern>
    </servlet-mapping>
    </web-app>
     
    4 - view.jsp
    hello word
     
    5 - POM
    <project xmlns="http://maven.apache.org/POM/3.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/maven-v4_0_0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<groupId>basic-web-app</groupId>
    	<artifactId>basic-web-app</artifactId>
    	<packaging>war</packaging>
    	<version>0.0.1-SNAPSHOT</version>
    	<name>basic-web-app Maven Webapp</name>
    	<url>http://maven.apache.org</url>
     
    	<dependencyManagement>
    		<dependencies>
    			<dependency>
    				<groupId>org.springframework</groupId>
    				<artifactId>spring-framework-bom</artifactId>
    				<version>4.0.6.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>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>3.8.1</version>
    			<scope>test</scope>
    		</dependency>
    	</dependencies>
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-compiler-plugin</artifactId>
    				<version>3.1</version>
    				<configuration>
    					<source>1.6</source>
    					<target>1.6</target>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>org.apache.tomcat.maven</groupId>
    				<artifactId>tomcat7-maven-plugin</artifactId>
    				<version>2.2</version>
    			</plugin>
     
    		</plugins>
     
    	</build>
    </project>

    When I look at Problem window I see
    Cannot change version of project facet Dynamic Web Module to 3.0. basic-web-app line 1 Maven Java EE Configuration Problem
    Java compiler level does not match the version of the installed Java project facet. basic-web-app Unknown Faceted Project Problem (Java Version Mismatch)
    One or more constraints have not been satisfied. basic-web-app line 1 Maven Java EE Configuration Problem
    Project facet Java 1.8 is not supported by target runtime Apache Tomcat v7.0. basic-web-app Unknown Faceted Project Problem


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    585
    Thanks
    0
    Thanked 106 Times in 91 Posts

    Default Re: ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

    Did you read this part of the error message:
    Project facet Java 1.8 is not supported by target runtime Apache Tomcat v7.0.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

    Thanks. I changed to 1.7 but I am still getting the same error from the subject of this thread.
    PS. instead of 5 lines in problem window now I have two but I don't know what to do:


    Cannot change version of project facet Dynamic Web Module to 3.0. basic-web-app line 1 Maven Java EE Configuration Problem
    One or more constraints have not been satisfied. basic-web-app line 1 Maven Java EE Configuration Problem

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,132
    My Mood
    Mellow
    Thanks
    187
    Thanked 659 Times in 646 Posts

    Default Re: ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

    Thread moved.

Similar Threads

  1. [SOLVED] "org.hibernate.Session" ClassNotFoundException
    By talha06 in forum Exceptions
    Replies: 3
    Last Post: August 21st, 2013, 11:13 AM
  2. Replies: 2
    Last Post: July 2nd, 2013, 04:59 PM
  3. glassfish ClassNotFoundException java.lang.ClassNotFoundException: ...
    By enginco in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: June 18th, 2012, 12:18 PM
  4. Replies: 3
    Last Post: March 7th, 2012, 04:54 AM
  5. Eclipse web.xml servlet mapping???
    By nikos in forum Java IDEs
    Replies: 2
    Last Post: October 24th, 2010, 05:30 AM