平时在开发过程中,总会遇到各种各样的异常,有时间就记载一下,以免下次再出现时就不用再问度娘了。
1、IOException while loading persisted sessions
严重: IOException while loading persisted sessions: java.io.EOFException
严重: Exception loading sessions from persistent storage
原因:tomcat对硬盘的session读取失败,
解决办法:将work下面的文件清空,主要是*.ser文件,或者只是删除掉session.ser即可以解决。
转载:http://www.blogjava.net/apple0668/archive/2007/10/12/152383.html
2、java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(DecimalFormat.java:487)
例子:为dj格式化
private Double field7;
private String dj;
public void setField7(Double field7) {
this.field7 = field7;
DecimalFormat df=new DecimalFormat("#.00");
this.setDj(df.format(field7));
}
public void setDj(String dj) {
this.dj = dj;
}
3、sequence does not exist
用惯了SQL Server,就知道native的主键策略,对这个sequence是一点都不清楚啊。
会报这个错通过都是因为insert数据时没有设置主键策略,所以在映射文件中设置一下,就可以了。
<id name="field1" type="java.lang.Integer">
<column name="FIELD1" precision="8" scale="0" />
<generator class="sequence">
<param name="sequence">TABLE1_SEQUEN</param>
</generator>
</id>
4、 Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
调用一个Hibernate的saveOrUpdateAll方法时报错:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
问题:只读模式下(FlushMode.NEVER/MANUAL)写操作不被允许:把你的Session改成FlushMode.COMMIT/AUTO或者清除事务定义中的readOnly标记。
导致这个问题的可能有多方面的原因,但目前我遇到的就只有两个方面的,都跟事务的配置有关系。
a、事务配置特性的问题,像这种
<tx:method name="find*" propagation="NOT_SUPPORTED" read-only="true"/>
有时候会因为有后面个read-only="true"而导致这个问题。所以去掉read-only='true'这个属性可能就能解决问题了。
b、配置事务中包的问题。
<aop:config proxy-target-class="true"><aop:pointcut id="allManagerMethod"
expression="execution(* com.dao.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
</aop:config>
有可能咱们自己写的方法没有在指定的包里面,把包的路径修改下,或者重新添加一个就OK了。如:
<aop:config proxy-target-class="true"><aop:pointcut id="allManagerMethod" expression="execution(* com.dao.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
</aop:config>
使用JSON解析时报错:NOClassDefFoundError :org/apache/commons/lang/exception/NestableRuntimeException
项目里面已经导入了json-lib包,还是报上面的错。最后发现是少了以下的JAR包:
commons-beanutils
commons-lang
commons-collections
commons-logging
ezmorph
6、Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject
这个是使用poi处理excel时报的错,添加xmlbeans-2.3.0.jar就OK。
7、java.lang.ClassNotFoundException: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet
这个也是使用poi处理excel时报的错,添加ooxml-schemas-1.1.jar就好了。