- log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
- log4j:WARN Please initialize the log4j system properly.
- Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbc' defined in class path resource [org/coffee/ssh/spring/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
- Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
- at java.lang.Class.getDeclaredConstructors0(Native Method)
- at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
- at java.lang.Class.getConstructor0(Unknown Source)
- at java.lang.Class.getDeclaredConstructor(Unknown Source)
- at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:752)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:717)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
- at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
- at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
- at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
- at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
- at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
- at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
- at org.coffee.ssh.Test.main(Test.java:17)
原因是工具myEclipse在建立SessionFactory的时候,少加一个包 commons-pool-1.3.jar 补上去问题解决。
下载apache 的 commons-pool/1.3/commons-pool-1.3.jar
该包下载地址
http://mirrors.ibiblio.org/pub/mirrors/maven2/commons-pool/commons-pool/1.3/commons-pool-1.3.jar
加到classpath里 或者 加到工程