java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21191544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
提问by ATJVS
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
我正在尝试在使用 tomcat 6 和 postgresql 9.1 的 tomcat 项目下将 org.apache.commons.dbcp.BasicDataSource 配置为 web.xml 中的 bean
my servletdispacher.xml
我的 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)
采纳答案by sparkle
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.
对于 Mint 15 上的 tomcat6 包,这发生在我身上。安装已经/usr/share/tomcat6/lib/commons-pool.jar -> ../../java/commons-pool.jar
但/usr/share/java/commons-pool.jar -> commons-pool-1.5.6.jar
被破坏了。从我的本地 Maven 仓库复制它为我sudo cp ~/.m2/repository/commons-pool/commons-pool/1.5.6/commons-pool-1.5.6.jar /usr/share/java
修复了它。
回答by mcsilvio
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.
似乎没有部署 'commons-pool' jar。如果您使用的是 eclipse,则可以通过转到项目的属性并单击部署程序集来检查部署了哪些 jar。
回答by Lalit Jawale
May be your commons-pool-x.x.x.jar
is not present in your lib folder in deployed folder this can be solved by copying this jar file in apache-tomcat-7.0.54\lib
folder
可能是你commons-pool-x.x.x.jar
的 lib 文件夹中没有你的部署文件夹,这可以通过在apache-tomcat-7.0.54\lib
文件夹中复制这个 jar 文件来解决
回答by Diwa
I too faced some problem, in my repo commons-pool2-2.1.jar is not downloaded properly. we need to download correct jar.
我也遇到了一些问题,在我的 repo commons-pool2-2.1.jar 中没有正确下载。我们需要下载正确的jar。