ssh框架开发中遇到的部分问题及解决方法

一开始用Struts+spring+hibernate 碰到了很多郁闷的问题,感觉特难。慢慢的遇到什么问题解决什么问题后感觉就没那么痛苦了,一般的问题也就能搞定了!现在放到blog里.一来嘛:方便复习,二嘛:为正在学习ssh框架的同行们提供点经验。

 在使用junitStrutsTest时候,报错:

java.lang.UnsupportedClassVersionError junitframeworkTestListener (Unsupported major.minor version 49.0)

原因是如果是jdk1.4的话,只能使用junit3.8以下版本,如果是使用jdk1.5的话,必须使用junit4.0以上版本。

javax.servlet.ServletException Cannot retrieve mapping for action companyNews

struts-config.xml中没有写相关companyNewsaction.

     Cannot find ActionMappings or ActionformBeans collection

原因可能是:web.xml文件中没有配置struts-config.xml的相关信息。

Failed to load or instantiate TagLibraryValidator class org.apache.taglibs.standard.tlv.JstlCoreTLV

standard.jar没有放在lib里面 或者是有其他版本冲突

    

hibernate3,对象中一对多的one方,必须写private Set pays=new HashSet();,否则包错java.lang.NullPointerException

hibernate2private Set pays;却不报错;

AbstractSaveEventListener - generated identifier 1, using strategy org.hibernate.id.IncrementGenerator

org.hibernate.PropertyValueException not-null property references a null or transient value com.xxx.yyy.company

at org.hibernate.engine.Nullability.checkNullability(Nullability.java72)

many to one 中的设置应该设置为not-null=false ,设置为not-null=true则报以上错误

javax.naming.NameNotFoundException Name hibernate_connection_factory is not bound in this Context

原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。

例如many-to-one设置了以后,仍然在其中设置相冲突的property属性。

java.lang.IllegalArgumentException id to load is required for loading

原因: session.load(Company.class,payForm.getCompanyId());

load()方法第二个参数必须是searlizable,并且必须是和数据库映射类的属性值类型一致,即使强制转换都不行。

org.hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed

解决办法。

 cmpy=(CompanyEdit)ss.load(CompanyEdit.class,companyId1);

   Hibernate.initialize(cmpy);强制初始化cmpy,否则ss.close(),cmpy将消失.

 或者加入lazy=false  取消延迟加载也可以 但是影响性能

Deployment is out of date due to changes in the underlying project contents . You'll need to mannally 'Redeploy' the project to update the deployed archive.

原因

tomcat 中部署的某个文件的拒绝访问影响了部署。

重启后,去除tomcat中部署的文件。重新在eclipse中设置部署。

[WARN] JDBCExceptionReporter - SQL Error 904, SQLState 42000

[ERROR] JDBCExceptionReporter - ORA-00904 无效列名

[INFO] DefaultLoadEventListener - Error performing load command org.hibernate.exception.SQLGrammarException could  ot load an entity [com.xxx.yyy.Sellinfo#1]

org.hibernate.exception.SQLGrammarException could not load an entity [com.xxx.yyy.Sellinfo#1]

.hbm.xml文件中的某个列名和数据库中的不同。

ConnectionManager - unclosed connection, forgot to call close() on your session

原因:没有关闭hibernatesessiontransaction。或者没有关闭session

[WARN] SellCommentDAO - org.hibernate.ObjectDeletedException deleted object would be re-saved by cascade (remove

deleted object from associations) [com.xxx.yyy.SellComment#7]

原因:父亲对象(one方)设置cascade=save-update 时,直接删除子对象时,会报错,

处理方法:save信息需要级联操作,delete时候也要用相同的原理。

SellComment sellComment=new SellComment();

sellComment = (SellComment)session.load(SellComment.class,sellCommentId);获取儿子对象

Long sellInfoId=sellComment.getSellInfo().getSellId();获取父亲id

SellInfo sellinfo=(SellInfo)session.load(SellInfo.class,sellInfoId);获取父亲对象

sellInfo.getSellComments().remove(sellComment);断绝父子关系

sellComment.setSellInfo(null);断绝子父关系

方法二:修改cascade=all  不是很好 可能其他地方不需要多余的级联降低性能

前几天发现原来很好用的系统总是报Unable to read TLD "META-INF/tlds/struts-bean.tld" from JAR file 错误.

具体错误信息为:

HTTP Status 500 -type Exception report

Message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /index.jsp(1,1) Unable to read TLD "META-INF/tlds/struts-bean.tld" from JAR file

"file:*****/WEB-INF/lib/struts.jar":

原因:测试发现更新了工程用的lib文件夹下的jar,发布时也发布了servlet.jarjsp-api.jar 它们有冲突

解决办法:

方法一:jsp-api.jar删除就解决这个问题了。

方法二:Tomcat换成6.0

我的解决办法:删除servlet.jar及与servlet相关的jar文件

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值