spring - java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource -


iam doing project on spring mvc maven.iam getting error java.lang.classnotfoundexception: org.apache.commons.dbcp.basicdatasource while running project.i include dependencies think..below codes.waiting reply

web.xml

  <?xml version="1.0" encoding="utf-8"?>   <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">   <servlet>  <servlet-name>accperspring</servlet-name>  <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>  <init-param>     <param-name>contextconfiglocation</param-name>     <param-value>/web-inf/servlet-context.xml</param-value>  </init-param>     <load-on-startup>1</load-on-startup>  </servlet>     <servlet-mapping>        <servlet-name>accperspring</servlet-name>        <url-pattern>/</url-pattern>     </servlet-mapping>  </web-app> 

servlet-context.xml

  <?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:mvc="http://www.springframework.org/schema/mvc"              xmlns:beans="http://www.springframework.org/schema/beans"   xmlns:context="http://www.springframework.org/schema/context"   xmlns:tx="http://www.springframework.org/schema/tx"   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/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">     <!-- enable @controller annotation support -->    <mvc:annotation-driven />      <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">          <property name="prefix" value="/web-inf/" />          <property name="suffix" value=".jsp" />    </bean>   <context:component-scan base-package="com.gerrytan.pizzashop"/>   <bean id="mydatasource" class=" org.apache.commons.dbcp.basicdatasource" destroy-method="close">         <property name="driverclassname" value="com.mysql.jdbc.driver"/>        <property name="url" value="jdbc:mysql://localhost:3306/mydatabase"/>        <property name="username" value="root"/>        <property name="password" value="kca@fnpl#12"/>  </bean>       <!-- hibernate session factory -->     <bean id="mysessionfactory"class="org.springframework.orm.hibernate4.localsessionfactorybean>     <property name="datasource" ref="mydatasource"/>     <property name="packagestoscan">     <array>      <value>com.gerrytan.pizzashop</value>     </array>    </property>     <property name="hibernateproperties">    <value>     hibernate.dialect=org.hibernate.dialect.mysqldialect    </value>    </property>    </bean>      <!-- hibernate transaction manager -->     <bean id="transactionmanager"    class="org.springframework.orm.hibernate4.hibernatetransactionmanager">     <property name="sessionfactory" ref="mysessionfactory"/>    </bean>     <mvc:resources mapping="/resources/**" location="/web-inf/resources/" />    <!-- activates annotation based transaction management -->    <tx:annotation-driven transaction-manager="transactionmanager"/>    </beans> 

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>accperspring</groupid>      <artifactid>accperspring</artifactid>       <version>0.0.1-snapshot</version>      <packaging>war</packaging>       <properties>      <spring.version>3.2.3.release</spring.version>       <hibernate.version>4.2.2.final</hibernate.version>       </properties>      <dependencies>      <!-- spring -->          <dependency>          <groupid>org.springframework</groupid>          <artifactid>spring-context</artifactid>          <version>${spring.version}</version>         </dependency>      <dependency>       <groupid>org.springframework</groupid>       <artifactid>spring-webmvc</artifactid>       <version>${spring.version}</version>     </dependency>    <dependency>      <groupid>org.springframework</groupid>      <artifactid>spring-orm</artifactid>      <version>${spring.version}</version>    </dependency>  <!-- hibernate --> <dependency>   <groupid>org.hibernate</groupid>   <artifactid>hibernate-core</artifactid>   <version>${hibernate.version}</version> </dependency>  <!-- java ee --> <dependency>   <groupid>javax.servlet</groupid>   <artifactid>servlet-api</artifactid>   <version>2.5</version>   <scope>provided</scope> </dependency> <dependency>   <groupid>jstl</groupid>   <artifactid>jstl</artifactid>   <version>1.2</version> </dependency>  <!-- others --> <dependency>   <groupid>commons-dbcp</groupid>   <artifactid>commons-dbcp</artifactid>   <version>1.4</version> </dependency> <dependency>   <groupid>mysql</groupid>   <artifactid>mysql-connector-java</artifactid>   <version>5.1.25</version> </dependency> <dependency>   <groupid>log4j</groupid>   <artifactid>log4j</artifactid>   <version>1.2.14</version> </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>      </plugins>      </build>   </project> 

once build completes check in war file-> web-inf/lib commons-dbcp-1.4.jar. if available in class path issue solved. 1 more thing is, open commons-dbcp-1.4.jar , check particular class(org.apache.commons.dbcp.basicdatasource) available or not? if not have try other versions of commons-dbcp-1.4.jar.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -