zoukankan      html  css  js  c++  java
  • 项目中遇到的一些异常

    一: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]
    解决方案:是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.*;

  • 相关阅读:
    bzoj 1017 魔兽地图DotR
    poj 1322 chocolate
    bzoj 1045 糖果传递
    poj 3067 japan
    timus 1109 Conference(二分图匹配)
    URAL 1205 By the Underground or by Foot?(SPFA)
    URAL 1242 Werewolf(DFS)
    timus 1033 Labyrinth(BFS)
    URAL 1208 Legendary Teams Contest(DFS)
    URAL 1930 Ivan's Car(BFS)
  • 原文地址:https://www.cnblogs.com/wx-ym-good/p/7172948.html
Copyright © 2011-2022 走看看