简体   繁体   中英

java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using tomcat 6 and postgresql 9.1

my servletdispacher.xml

`

<bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/jsp/"
      p:suffix=".jsp" />




<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost:5432/car" />
    <property name="username" value="postgres" />
    <property name="password" value="123" />
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="annotatedClasses">
        <list>
            <value>DAOModel.Tblusers</value>
        </list>
    </property>
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="DAOModel.Tblusers" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>
</bean>

` and error which get :

javax.servlet.ServletException: Servlet.init() for servlet dispatcher threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:724)

It seems the 'commons-pool' jar is not being deployed. If you are using eclipse, you can check which jars are deployed by going to the project's properties, and clicking Deployment Assembly.

This happened to me for the tomcat6 package on Mint 15. The installation had /usr/share/tomcat6/lib/commons-pool.jar -> ../../java/commons-pool.jar but /usr/share/java/commons-pool.jar -> commons-pool-1.5.6.jar was broken. Copying it from my local Maven repo sudo cp ~/.m2/repository/commons-pool/commons-pool/1.5.6/commons-pool-1.5.6.jar /usr/share/java fixed it for me.

可能是您的commons-pool-xxxjar不存在于已部署文件夹的lib文件夹中这可以通过在apache-tomcat-7.0.54\\lib文件夹中复制此jar文件来解决

I too faced some problem, in my repo commons-pool2-2.1.jar is not downloaded properly. we need to download correct jar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM