JAVA错误处理大集合
30,
Caused by:
java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [business.impl.PriceBiz] for property ''priceBiz'': no matching editors or conversion strategy found
在java类中设置priceBiz时应该设置的是接口PriceBizIf,而非实现类
18, 数组越界
可能1: 在命令行后面需要加入参数.
可能2:加入的参数错误
19, car is not mapped
可能1: 在cfg.xml中没有增加映射的hbm.xml文件在<mapping.../>中
20, 属性没有找到
可能1: hbm.xml文件中的 <property name =""> 有问题, 也许是name的值与对应类中的成员名不一致
21,SQLException: 无当前连接 可能1:在比如创建帐户时没有对相应的方法添加到<list>中去,比如这个没有加入:<value>newAccount</value>
<bean id="transactionAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="advice">
<ref bean="advice"/>
</property>
<property name="mappedNames">
<list>
<value>transfer</value>
</list>
</bean>
22,SQLException: Syntax error: Encountered "table" at line 1, column 8.
可能1;执行SQL时出现冲突,可能是SQL语句中使用了关键字作为变量来用,比如
update order set balance=1000000;
其中order被用作表名来使用,这是错误的,因为order是个关键字,用在order by中
23, Servlet /Spring-WebMvc threw load() exception
org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
jar包的冲突,spring-1.2.6.jar和spring.jar出现在一个war的目录中:JBoss/server/all/deploy/Spring-WebMvc.war/WEB-INF/lib
24, java.sql.SQLException: 当事务仍处于活动状态时,无法关闭连接。
25 ,
validateJarFile(/home/soft01/Tomcat/webapps/sms-token-struts/WEB-INF/lib/servlet-api.jar)
Servlet /sms-struts-tiles threw load() exception
java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
原因:在WEB-INF/lib/ 目录下有servlet-api.jar与/Tomcat/common/lib目录下的servlet-api.jar冲突了,把WEB-INF/lib/下的servlet-api.jar删除就可以了
26,java.lang.ClassNotFoundException: org.springframework.web.struts.ContextLoaderPlugIn
Marking servlet action as unavailable
10:30:47,088 ERROR [/NetCT_OSS]:3953 - Servlet /NetCT_OSS threw load() exception
javax.servlet.UnavailableException
27,org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
缺少MyEclipse/eclipse/plugins/com.genuitec.eclipse.springframework_5.5.0/data/2.0/dist/modules/spring-struts.jar
28,Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (SD0702.FK82D343CF49A4B831) violated - parent key not found
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
有可能是ID生成策略的问题,我将它XML映射文件改成<generator class="increment" />就好了
29,
2007-08-19 16:21:43,290 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/OSS].[action]] - Servlet.service() for servlet action threw exception
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [entity.Module#2]
java.util.ConcurrentModificationException
原因:已经有对象拥有了所选择的module,用clear(),而不是remove();
30,
ERROR [org.apache.catalina.session.ManagerBase] - IOException while loading persisted sessions: java.io.InvalidClassException: entity.Module; local class incompatible: stream classdesc serialVersionUID = -5988350031935445758, local class serialVersionUID = -297934247726484429
java.io.InvalidClassException: entity.Module; local class incompatible: stream classdesc serialVersionUID = -5988350031935445758, local class serialVersionUID = -297934247726484429
在Module中加上一个关键字:transient
31,
Caused by: java.sql.BatchUpdateException: ORA-02292: integrity constraint (SD0702.SYS_C00132664) violated - child record found
原因:有其他的表引用了该表的外建,所以报这个异常,如果没有引用就不会出现
32,
出现数组越界的时候,看看是不是循环时没有加=,比如:
for(int i = 1; i<arr.length;i++)可以改成
for(int i = 1; i<=arr.length;i++)
1.如果使用Ant和Junit是被报找不到test,检查一下是否误用了private
出错信息:
<failure message="No tests found in test.AllTest" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: No tests found in test.AllTest
该错误有个很特别的特点,当你不通过ant来运行测试,而是通过AllTest类来运行的话,可以正常运行。小心哦
2.如果遇到报:表名无效,且jvm报严重错误,看看是不是用了数据库的保留关键字来做表名了,如User。
3.使用ant时必须小心ant的classpath它用的不是IDE的classpath,小心!
4.小心下边的异常,
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of xp.bean.Users.?" type="net.sf.hibernate.PropertyAccessException">java.lang.ClassCastException at xp.bean.UsersMetaClass1.setPropertyValues(<generated>) at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues
上次出现该错错误的原因是:
源文件里我的class类型为一个类Contact contact
而跑到mapping里却成了Set,呵呵厉害。
5.突然间冒出大量的NullPointException
重新build一下看看先。
6.="Flush during cascade is dangerous - this might occur if an object was deleted and then re-saved by cascade"
7.Tapestry的出错信息:
Class com.bookshop.Hello does not implement the IPage interface.
location: context:/WEB-INF/Home.page, line 6
原因:与显示有关的哪个java类没有从IPage家族继承。
8.使用ant时给出的路径好象不允许出现空格。
9.由于使用ant时用junit做测试的话,classpath中出现j2ee.jar的话,问题多多。例如xml格式的log文件生成不了,莫名其妙的NullPointException等。所以我设置了两个包个包含j2ee.jar,为编译用;一个没有,为junit用
10.进行单元测试时,在查询返回后应马上assertNotNull(),这样可以更快速的定位NullPointException
11.要使用ResourceBundle的话,要千万小心。必须用日志记录下它的状态。还有该属性文件应该放在classes下面。
12.当要显示任何页面时,都被提示无效,那么应该检查一下lib目录了,还有一些很奇怪的异常,例如你明明可以找到一个类但是服务器却提示ClassNotDefException,那么估计是缺少了该类所必须的包了。或者多了不兼容的包,如, xdoclet系列包不被struts的lib目录所兼容
推荐文章 |
