异常集锦

来源:互联网 发布:红帽linux版本 编辑:程序博客网 时间:2024/06/10 14:43
1、java.lang.IllegalStateException在非法或不适当的时间调用方法时产生的信号。换句话说,即 Java 环境或 Java 应用程序没有处于请求操作所要求的适当状态下。比如PrintWrite() out=new PrintWrite();数据库查询出现:java.lang.IllegalArgumentException: An exception occured while creating a query in EntityManager2、Internal Exception: line 1:41: expecting token in range: '1'..'9', found '<EOF>'原因是在ejb中进行数据查询时应为select t from uer t where where t.id=?1 and t.type=?2 不能 select t from uer t where where t.id=? and t.type=?数据库查询出现:java.lang.IllegalArgumentException: Negative Start Position is not allowed 原因1、分页查询时,page为0 从而进行query.setFirstResult((page - 1) * numberOfPage)查询时,出错3、JasperException:quote symbol expected 原因:一般是由于书写格式不正确,比如应使用引号在中文方式下输入4、Invalid byte 2 of 2-byte UTF-8sequence.

      由于xml文档的实际编码跟定义的编码不一致。解决方法:使用EditPlus对xml文档进行重新编码,使实际编码与定义编码一致

5、使用jdom读取xml文件出错java.net.MalformedURLException: unknownprotocol: d       atjava.net.URL.<init>(URL.java:574)       atjava.net.URL.<init>(URL.java:464)       atjava.net.URL.<init>(URL.java:413)解决方法:在读取xml文件的时候 Document doc = sb.build("file:\"+xmlFileName);加上"file:\"