spring3.0+hibernate3.3+mysql5.0+c3p0出错,谢谢!!
直接用jsp连接jndi,成功读取。整合实验出错了,可以帮我看下吗?谢谢!!applicationContext.xml:<beanid="dataSourcetarge...
直接用jsp连接jndi,成功读取。整合实验出错了,可以帮我看下吗?谢谢!!
applicationContext.xml:
<bean id="dataSourcetarget"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/mysql"></property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
<property name="targetDataSource">
<ref bean="dataSourcetarget" />
</property>
<property name="username" value="root"></property>
<property name="password" value="hello"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="jndi.url">
jdbc:mysql://localhost:3306/test
</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>./User.hbm.xml</value></list>
</property></bean>
<bean id="UserDAO" class="UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean></beans>
出错:
2013-4-7 19:44:20 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet ServletTest threw exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/impl/NewProxyDatabaseMetaData
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403) 展开
applicationContext.xml:
<bean id="dataSourcetarget"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/mysql"></property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
<property name="targetDataSource">
<ref bean="dataSourcetarget" />
</property>
<property name="username" value="root"></property>
<property name="password" value="hello"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="jndi.url">
jdbc:mysql://localhost:3306/test
</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>./User.hbm.xml</value></list>
</property></bean>
<bean id="UserDAO" class="UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean></beans>
出错:
2013-4-7 19:44:20 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet ServletTest threw exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/impl/NewProxyDatabaseMetaData
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403) 展开
1个回答
2013-04-07
展开全部
com/mchange/v2/c3p0/impl/NewProxyDatabaseMetaData
c3p0 的.jar不在lib、CLASSPATH中
c3p0 的.jar不在lib、CLASSPATH中
追问
在tomcat和项目下我都放了c3p0和mysql的jar包
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询