博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
项目中遇到的一些异常
阅读量:4473 次
发布时间:2019-06-08

本文共 3577 字,大约阅读时间需要 11 分钟。

一:Tomcat启动时报出错误

1:

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]
解决方案:是web,xml(我这里用的是spring,修改的web.xml)里面配置缺少“/”(我这里遇到的是<servlet>配置里面没写对)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
二.在Json对象和java对象转换是抛出:
net.sf.json.JSONException: java.lang.NoSuchMethodException
原因是:无法初始化java对象(即找不到一个合适的构造方法)
解决方案:在java对象中写一个无参的构造方法
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 三.关于基本数据类型
问题:我在遍历map集合时:

其中我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.*;

转载于:https://www.cnblogs.com/wx-ym-good/p/7172948.html

你可能感兴趣的文章
Mysql的DATE_FORMAT()日期格式转换
查看>>
vue实战教程
查看>>
SparkStreaming入门及例子
查看>>
Web应用增加struts2支持
查看>>
java程序——凯撒加密
查看>>
Windows Store App之数据存储
查看>>
English class 82 The Importance of traveling
查看>>
python用递归函数解汉诺塔游戏
查看>>
Redis与Python交互
查看>>
Maximum-SubsequenceSum
查看>>
常用的一些shell变量
查看>>
Android无法删除项目+导入项目报错
查看>>
poj 2349(最小生成树应用)
查看>>
Shell编程-条件测试 | 基础篇
查看>>
AngularJs学习笔记1——总体介绍
查看>>
C语言第十二讲,文件操作.
查看>>
绝对定位和相对定位
查看>>
实习第二天——学习mac终端命令(unix命令)和git代码管理
查看>>
微信支付
查看>>
吴裕雄--天生自然 高等数学学习:含参变量的积分
查看>>