`
___loveOfForever
  • 浏览: 75693 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

SSH异常处理与解决办法

阅读更多
1.struts1.2+hibernate3.1+spring2.0整合的时候如果在注入的时候变量命名不规范如sCarSell,则spring会报错: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sCarSell' of bean class [com.kingtoon.count.struts.action.CountAction]: Bean property 'sCarSell' is not writable or has an invalid setter method. Did you mean 'SCarSell'?

解决方法:改变量名->secCarSell

2.启动tomcat的时候跳出这样的错误,IOException while loading persisted sessions: java.io.EOFException

解决方法:到tomcat安装目录下的work里面找相关工程下的SESSIONS.ser等有ser后缀的文件删掉,重启tomcat就ok了

3.ssh整合找不到action

参考地址:http://topic.csdn.net/u/20071003/17/c45495ce-e59a-45ad-a703-8ba42d4db8b1.html

4. javax.servlet.jsp.JspException: You must specify exactly one of src, srcKey, page, or pageKey

这个错误原因很简单,主要是我原来用的<img src="" /> 而后来想换成struts<html:img /> 但是我没填好里面的属性就关机了,第二天运行发现错误慢慢找发现了.把struts标签删掉就OK了.

5 .在映射文件里面配置一对多双向关联的时候,如果配置少了一些一些属性,则启动tomcat的时候会报错:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.iss.mycar.po.OnlineQa column: consultant_id (should be mapped with insert="false" update="false")
Caused by:
org.hibernate.MappingException: Repeated column in mapping for entity: com.iss.mycar.po.OnlineQa column: consultant_id (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:652)

解决办法是:在映射文件<many-to-one> 标签里面添加 insert="false"  update="false" 就可以解决了。

6.Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row

count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)


这个异常是我的mysql 数据库里面的ID是自增长的,但是我插入对象的时候指定了ID,所以报错!

使用的是hibernate的saveOrUpdate方法保存实例。saveOrUpdate方法要求ID为null时才执行SAVE,在其它情况下执行UPDATE。在保存实例的时候是新增,但你的ID不为null,所以使用的是UPDATE,但是数据库里没有主键相关的值,所以出现异常。

解决办法是:不指定ID 让数据库自动添加。

6.java.lang.IllegalArgumentException: argument type mismatch

这个错误主要是actionForm里面数据对应到的页面数据类型不匹配造成,花了我几个小时来找555555

解决办法:把actonForm里面的类型改成页面对应的类型。

7.javax.servlet.ServletException: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

这个原因是我用this.getHibernateTemplate().getSessionFactory().getCurrentSession()来生成session

后来把这句话改成this.getHibernateTemplate().getSessionFactory().openSession(); 就解决了!
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics