SSH整合连接ORACLE,老是出错,大家帮忙看看,多谢!

heyu1000 2014-12-09 09:38:06
struts没问题,主要是加上spring和Hibernate就出错,提示sessionFactory没创建成功,配置如下:

<?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:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">


<!-- 数据库连接 -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value> </property>
<property name="url"><value>jdbc:oracle:thin:@127.0.0.1:1521:orcl</value> </property>
<property name="username"> <value>myuser</value></property>
<property name="password"> <value>myuser</value> </property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<!-- 数据库连接 -->
<property name="dataSource">
<ref local="dataSource"/>
</property>
<!-- hibernate自身属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<!-- 解决no session found -->
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.myssh.model.Userinfo</value>
</list>
</property>
</bean>

<!-- 用户Dao -->

<bean id="userDao" class="com.myssh.daoimpl.UserinfoDAOImpl" scope="singleton">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

<!-- 用户Service -->
<bean id="userService" class="com.myssh.serviceimpl.UserinfoServiceImpl" scope="singleton">
<property name="userDao">
<ref local="userDao"/>
</property>
</bean>

<!-- 用户Action -->
<bean id="saveUserAction" class="com.myssh.controller.MyInsert" scope="prototype">
<property name="userService">
<ref local="userService"/>
</property>
</bean>


</beans>




错误信息如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/CursorableLinkedList
...全文
212 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
袭冰 2014-12-17
  • 打赏
  • 举报
回复
看看你的项目添加完包之后有没有编译成功
heyu1000 2014-12-11
  • 打赏
  • 举报
回复
commons-collections.jar commons-collections-3.2.jar不是一样的吗?
冰思雨 2014-12-09
  • 打赏
  • 举报
回复
应该不是配置文件的问题,就是缺少jar包的问题。 你把jar包都删了,当然什么都缺了。 commons-collections.jar commons-collections-3.2.jar commons-dbcp-1.2.2.jar commons-pool.jar 这几个jar包,你缺哪一个?
heyu1000 2014-12-09
  • 打赏
  • 举报
回复
如果我把tomcat中webapps中这个项目部署文件里的lib全部删除,然后再重新启动tomcat,在启动tomcat的时候就会报错,如下: 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 我的WEB.XML配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
	
<welcome-file-list> 
	<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

<!-- struts2拦截器 --> 
<filter> 
<filter-name>struts2</filter-name> 
	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
</filter> 

<filter-mapping> 
	<filter-name>struts2</filter-name> 
	<url-pattern>/*</url-pattern> 
</filter-mapping>

 <!-- 创建spring工厂监听器  -->
<listener> 
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

 <!-- 告知spring context config location 的存储位置   -->
<context-param> 
	<param-name>contextConfigLocation</param-name> 
	<param-value>/WEB-INF/classes/applicationContext.xml</param-value> 
</context-param> 


</web-app> 
不知道会不会是web.xml配置有问题,但是里面就这么几行呀。
heyu1000 2014-12-09
  • 打赏
  • 举报
回复
我是用myeclipse启动tomcat的时候就报错了
heyu1000 2014-12-09
  • 打赏
  • 举报
回复
我用了commons-collections3.2.1还是同样的报错!
冰思雨 2014-12-09
  • 打赏
  • 举报
回复
新添加的jar包,要放在项目路径里面,并且,项目要重新部署才能生效。楼主核实一下哈。
冰思雨 2014-12-09
  • 打赏
  • 举报
回复
如果hibernate里面没有,那就一定是在spring里面,找一找。一般都有的。
冰思雨 2014-12-09
  • 打赏
  • 举报
回复
很明显缺jar包啊。缺少apache的 commons-collections 的jar包。 楼主去spring或者hibernate的压缩包里翻一翻,找个版本高的放进去基本就可以了。一般都有的,如果没有,就去apache的官网下载一个。
姜小白- 2014-12-09
  • 打赏
  • 举报
回复
去官网看看 http://commons.apache.org/proper/commons-collections/download_collections.cgi 我的网速有点低,这个一直没打开 你打开下载下高版本的Commons jar包,试试看
heyu1000 2014-12-09
  • 打赏
  • 举报
回复
我是用的hibernate4.1.9,里面没有这个包呀,我看hibernate3.6里面才有这个包,刚刚我加了commons-collections-3.1.jar 进去之后,还是不行
姜小白- 2014-12-09
  • 打赏
  • 举报
回复
缺少 commons-collections-3.2.jar ,下载个添加进去再起试试看

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧