-
struts+hibernate项目debug总结
2006-12-20
转:
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();
-
一个手机引发的嘲笑
2006-12-17
手机本身是不会引起嘲笑的,引起嘲笑的是发生在手机主人身上的事
话还得从那个午后说起,在兴高采烈得做好前往图书馆的准备之后,xzy去上了一次厕所,在他回来时,带回来的是一个浑身上下湿透的手机——就是那个能够发出吵醒整个寝室却吵不醒他本人的闹钟音量的手机——在他一边骂骂咧咧得责怪着自己人品的同时,他告诉了我们事情的经过。
在离开寝室后,xzy跑到了厕所的大号位上去小解。虽然这件事本身就相当不正常,但更奇怪的事情还在后面:他的那个摩托罗拉的手机,居然从他的口袋里蹦了出来!!!
虽然他本人猜测说是因为口袋太浅的原因,但我们所有人都对此感到很不可思议,多少次都没有出事,就这么一次,未免也太~~~奇怪了,但是如果其中还有什么不可告人的原因我们恐怕也就不得而知了……
那个手机从口袋出来就应该做一个自由落体运动,在下落大约一米左右的高度后与水泥地面来一次亲密接触,在这样的速度下,就算是NOKIA的手机也应该会碎得四分五裂了,本来这没有什么值得奇怪的,但偏偏在此时又发生了一件奇事:手机完全没事,而且在落地后居然脚底摸油——溜了。
我们完全无法猜测那时手机的心态,究竟是因为在落地后害怕主人的责罚或者是已经无法忍受主人的摧残而找了这个机会逃跑抑或是在落地后看到远处有一个漂亮的女手机而想乘机去搭讪我们已无从得知……
总之,这个逃亡的手机最后是在隔壁的坑位里被发现的,xzy用了不少于5张的草纸进行擦干,在晚上又花了将近一个小时用电吹风为手机维修,无数尝试后,终于宣布手机寿终正寝。
之后等待xzy的就是无穷无尽的嘲笑了,就如friends中mon曾经说过的:“I think the length of teasing is directly related to how insane you were so, a long time.”这个故事已经完全可以有和dzy射失点球相同的生命力了……
“如果我们一开始就会走到一起的概率相当于小便时把兜里手机掉到隔壁的坑位里的几率的话,那么我们走到终点就像这台手机会报废那样必然!”
估计手机引发的嘲笑还会持续相当长的一段时间
-
puzzle game
2006-11-18
晚上的时候小头叫我一起去玩一个游戏
很有趣的一个东西
在BBS,google,以及若干工具的帮助下终于花了半个小时过关了,分享一下心得
Q1:一个ip地址,输入这个ip地址看到内容就明白是什么了
Q2:一道脑筋急转弯的题目
Enter a number below, and go to level 3.
看清楚了,enter a number……
Q3:
Good job! Let's take a break, and enjoy a little joke!
A foreigner was travelling in the US, and he hit an American accidentally in a corner.
The foreigner: I am sorry.
American: OH! I'm sorry, too.
The foreigner: I am sorry, three.
American: What are you sorry for?
The foreigner: I am sorry, five.Ok, let's go to level 4.
完全不明白什么意思,在随便输入一些之后看到错误提示是:
That's not good. ^_^ You don't need this!
晕……直接在地址栏输入levelfour进入下一关……
Q4:
What do you think of this?
000000
ff0000
ff0000 + 00ff00如果对网页制作稍微熟悉一点,就会看出这个是颜色的HEX代码……
然后是什么意思呢……
想像一下这三种颜色上下排列的东西吧……
Q5:
一张完全不知所谓的地图,唯一看得出的就是这是月球上的地图……
之后在BBS上看到这张地图和美国登月相关的……Apollo 15
Q6:
搜一下,发现是沃尔马的格言……
Q7:
很冷……你自己看着办吧……
Q8:
一开始完全看不懂,直到发现在between和us之间还有张图片……
OMG……
Q9:
看标题:thecodeisonthispage……
参照Q2……
Q10:
一看就直到是ANSII的编码~hoho,LOVE~~
-
GDI+中发生一般性错误的解决办法
2006-11-12
在开发.NET应用中,使用 System.Drawing.Image.Save 方法而导致“GDI+ 中发生一般性错误”的发生,通常有以下三种原因:
1. 相应的帐户没有写权限。
解决方法:在IIS中赋予帐户该网站目录的写权限。
2. 指定的物理路径不存在。
解决方法:
在调用 Save 方法之前,先判断目录是否存在,若不存在,则创建。
if (!Directory.Exists(dirpath))
Directory.CreateDirectory(dirpath);
3. 保存的文件已存在并因某种原因被锁定。
解决方法:
重启IIS,解除锁定。并在代码中使用 using 语句,确保释放 Image 对象所使用的所有资源。 -
SQL Server2000-孤立用户的解决办法
2006-11-12
把婚礼网部署到用户的服务器上之后,问题一个接一个得出来
在解决了前一个问题后,数据库的登陆又出了问题
在察看后,基本判断是因为数据库还原后导致数据库中出现孤立用户。产生孤立用户的原因就是保存在数据库的sysusers表中的用户的ID和保存在master.dbo.syslogins的登录ID有出入,造成用户和数据库登录不能联系起来,引起存储过程不能用,权限不能归还用户等等问题,而且这种孤立在数据库中的用户是不能在企业管理器中删除、修改的。
简而言之就是这个用户没有对应的登陆。
微软对此的解决办法之一是删除该用户,但因为在开发过程中,所有的存储过程以及表都是属于该用户的,删除肯定不现实的解决办法。最好的办法就是修复用户和登陆之间的关联。
首先建立起相关的登陆,之后执行下面的指令:
exec sp_configure 'allow updates',1 reconfigure with override
update db set sid=s.sid
from dbname.dbo.sysusers db
join master.dbo.syslogins s on db.name=s.name
where db.sid != s.sid and db.islogin=1
exec sp_configure 'allow updates',0 reconfigure with override或者还可以用:
use databasenamegoexec sp_change_users_login 'update_one','孤立用户名','新登陆名'go这样就可以了。
但之前用户在还原数据库时把数据库的名字以数字开头,之后执行起来就一直不正确……结果只得重新还原部署一遍……







