一:Tomcat启动时报出错误
1:Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext
05-Dec-2016 11:23:44.321 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChi
ld: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext
[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Unable to complete the scan
for
annotations
for
web application [] due to a StackOverflo
wError. Possible root causes include a too low setting
for
-Xss and illegal cyclic inheritance dependencies. The class hierarchy bei
ng processed was [org.bouncycastle.asn1.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1Enc
odableVector]
其中我getValue()出来的值理论上是Double类型,编译也没有异常(注意我score类里的数据也是Double类型的),抛出
异常:java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
解决:上图是错误显示的,解决方案在图中倒数第二行的代码,先将entry.getValue()转换为字符串,再转换为Double类型即可。原因我也没有想明白,后面看到的小伙伴能明白的求解释下
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
四:存储数据库时,字段长度不够造成
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'receiver_state' at row 1
解决方法(推荐参考):http://www.cnblogs.com/kqchi741/archive/2010/04/04/jsp.html
我这个里是因为数据库上面定义的字段长度不够
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
五:在迭代器迭代时遇到异常:
java.util.ConcurrentModificationException
原因:在使用iterator.hasNext()操作迭代器的时候,如果此时迭代的对象发生改变,比如插入了新数据,或者有数据被删除。
当集合A已经生成过iterator it之后,若要对此集合进行操作,只能访问it,不能够再次直接引用A
解决办法:
1) 通过Iterator修改Hashtable
while(it.hasNext()) {
Object ele = it.next();
it.remove();
}
2) 根据实际程序,您自己手动给Iterator遍历的那段程序加锁,给修改HashMap的那段程序加锁。
3) 使用“ConcurrentHashMap”替换HashMap,ConcurrentHashMap会自己检查修改操作,对其加锁,也可针对插入操作。
import java.util.concurrent.*;