xml - Servlet [mvc-dispatcher] in web application threw load() exception java.lang.ClassNotFoundException -
hello new spring , trying build simple spring mvc project when running code getting: servlet [mvc-dispatcher] in web application threw load() exception java.lang.classnotfoundexception
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_2_5.xsd" version="2.5"> <display-name>sample spring maven project</display-name> <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
spring-config.xml is
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/ 2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:component-scan base-package="com.newproject.controller" /> <context:property-placeholder location="classpath:database.properties" /> <mvc:annotation-driven /> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="driverclassname" value="${database.driver}" /> <property name="url" value="${database.url}" /> <property name="username" value="${database.user}" /> <property name="password" value="${database.password}" /> </bean> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="annotatedclasses"> <list> <value>com.newproject.domain.employee</value> </list> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.mysql5dialect</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> </props> </property> </bean> <bean id="txmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="persistenceexceptiontranslationpostprocessor" class="org.springframework.dao.annotation.persistenceexceptiontranslationpostpro cessor" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> <bean id="datadaoimpl" class="com.newproject.dao.datadaoimpl" /> <bean id="dataserviceimpl" class="com.newproject.services.dataserviceimpl"/> </beans>
pom.xml
<modelversion>4.0.0</modelversion> <groupid>com.newproject</groupid> <artifactid>newproject</artifactid> <version>0.0.1-snapshot</version> <packaging>war</packaging> <name>mynewproject</name> <url>http://maven.apache.org</url> <properties> <spring.version>4.0.5.release</spring.version> <hibernate.version>4.3.5.final</hibernate.version> <log4j.version>1.2.17</log4j.version> <jdk.version>1.7</jdk.version> <context.path>springhibernateannotations</context.path> </properties> <developers> <developer> <id>nagesh chauhan</id> <email>beingjavaguy@gmail.com</email> <organization>beingjavaguys.com</organization> <organizationurl>http://www.beingjavaguys.com</organizationurl> <roles> <role>java developer</role> </roles> <timezone>+5:30</timezone> </developer> </developers> <build> <finalname>${pom.artifactid}</finalname> <plugins> <!-- maven compiler plugin --> <plugin> <artifactid>maven-compiler-plugin</artifactid> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>log4j</groupid> <artifactid>log4j</artifactid> <version>${log4j.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-orm</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-jdbc</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-web</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-entitymanager</artifactid> <version>${hibernate.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>jstl</groupid> <artifactid>jstl</artifactid> <version>1.2</version> </dependency> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.6</version> </dependency> </dependencies> </project>
i had same error. running spring mvc project in eclipse (luna). had "build automatically" option turned off , creating problems. try switch on , try run project again.
Comments
Post a Comment