Junky's IT Notebook

统计

留言簿(8)

积分与排名

WebSphere Studio

阅读排行榜

评论排行榜

struts+hibernate项目debug总结

转:

javax.servlet.ServletException: Cannot retrieve mapping for action /companyNews

struts-config.xml中没有写相关companyNews的action.

============================================
在myeclipse增加一个jar包时候,先打开项目properties,选择java build path --> libraries -->add external JARs 选择到需要的jar包,加入后,发现,他这个包加载的是绝对路径,而我们的项目需要cvs共享,无法

commit到cvs服务器。myeclipse有以下提示信息:
2 build path entries are missing.

解决办法是,关闭myeclipse,用notepad打开项目目录下的 .classpath, 手动修改成相对路径,并且检查,指定的相对路径中是否真正添加了jar包,
启动myeclipse就可以上传新添加的jar包了。


=============================================
在使用junit/StrutsTest时候,报错:
java.lang.UnsupportedClassVersionError: junit/framework/TestListener (Unsupported major.minor version 49.0)

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






==========================================================

Cannot find ActionMappings or ActionformBeans collection
原因是:web.xml文件中没有配置struts-config.xml的相关信息。


============================================================

org.apache.jasper.JasperException: The absolute uri:
http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application


缺少jstl的相关jar和web.xml配置
jstl.jar

 
http://java.sun.com/jstl/fmt
  /WEB-INF/fmt.tld



 
http://java.sun.com/jstl/fmt-rt
  /WEB-INF/fmt-rt.tld



 
http://java.sun.com/jstl/core
  /WEB-INF/c.tld



 
http://java.sun.com/jstl/core-rt
  /WEB-INF/c-rt.tld



 
http://java.sun.com/jstl/sql
  /WEB-INF/sql.tld



 
http://java.sun.com/jstl/sql-rt
  /WEB-INF/sql-rt.tld



 
http://java.sun.com/jstl/x
  /WEB-INF/x.tld



 
http://java.sun.com/jstl/x-rt
  /WEB-INF/x-rt.tld



==========================================================

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


standard.jar没有放在lib里面


===========================================================

创建oracle表的时候,使用了,role和comment关键字,建议不要将这两个关键字作为表名和字段名。
建议用toad或plsql developer创建表,这样软件会提示关键字。
=============================================================

[ERROR] XMLHelper - Error parsing XML: XML InputStream(18) Attribute name "column" associated with an element type "key" must be followed by the ' = ' character.
[ERROR] Configuration - Could not configure datastore from input stream

must be followed by the ' = ' character. Nested exception: Attribute name "column" associated with an element type "key" must be followed by the ' = ' character.>org.dom4j.DocumentException: Error

on line 18 of document : Attribute name "column" associated with an element type "key" must be followed by the ' = ' character. Nested exception: Attribute name "column" associated with an element

type "key" must be followed by the ' = ' character.



xml 语法错误,key语法中应该类似这样的写法
=============================================================
hibernate3,对象中一对多的one方,必须写private Set pays=new HashSet();,否则包错java.lang.NullPointerException ,
而hibernate2中private Set pays;却不报错;

=============================================================
[DEBUG] 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.java:72)

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


org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.xxx.yyy.Company

在save的同时也需要save其他的表,然后再flush()
=========================================================================

Parse Fatal Error at line 12 column 1

struts-config.xml文件被修改,语法错误。检查语法。

========================================

org.hibernate.QueryException: could not resolve property: userid of: com.xxx.yyy.Pay

使用到外键userid的时候,必须使用userinfo.userid方法才能得到。

=========================================
javax.naming.NameNotFoundException: Name hibernate_connection_factory is not bound in this Context
原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。
例如many-to-one设置了以后,仍然在其中设置相冲突的属性。

==========================================

[WARN] RequestProcessor - Unhandled Exception thrown: class java.lang.NullPointerException
必须将使用到的对象new起来。

============================================
GROUP BY 表达式的查询必须满足如下:
select 子句后的每一项必需出现在group by 子句中,除非该项使用了聚集函数。

===========================================
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.xxx.yyy.Company

要级联保存,多次session.save()
==============================================
java.lang.IllegalArgumentException: id to load is required for loading
原因:

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


=============================================
[INFO] DefaultLoadEventListener - Error performing load command
>org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xxx.yyy.Company#0]


表示你现在查询的对象所关联的对象有问题,一般是因为数据的问题(该对象所关联的对象找不到),数据的错误,影响了程序正常执行。

========================================================
eclipse 3.1,myeclipse 4错误
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中设置部署。
为什么需要重启?
因为:google desktop软件正在对我部署的一个300MB大文件进行索引,锁定了这个大文件,我估计google desktop需要对这个文件索引半个小时以上。因此,eclipse无法对过去部署的文件,做先删除后重新部署的工作。

===================================================
ERROR LazyInitializationException:19 - could not initialize proxy - the owning Session was closed

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将消失.

====================================================
javascript错误
行: 56
字符: 45
错误: 未结束的字符串常量
代码: 0

是编码的问题!用ANSI编码另存后就好了。

====================================================
[WARN] JDBCExceptionReporter - SQL Error: 904, SQLState: 42000
[ERROR] JDBCExceptionReporter - ORA-00904: 无效列名

[INFO] DefaultLoadEventListener - Error performing load command
>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?


原因:没有关闭hibernate的session的transaction。或者没有关闭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);//断绝子父关系
session.delete(sellComment);//删除儿子
session.flush();

posted on 2007-03-09 18:12 junky 阅读(750) 评论(0)  编辑  收藏 所属分类: hibernate


只有注册用户登录后才能发表评论。


网站导航: