java程序在停止时调用系统钩子为什么会有NoClassDefFoundError产生?

曾杰 发布于 2013/08/02 17:07
阅读 816
收藏 0

程序在控制台跑着一段时间后,按CRTL+C中断后调用shuthook,就会有下面这样的错误,我想问下这是怎么产生的?怎么避免?有人遇到过么?windows上

2013-08-02 17:02:01,081 - cn.com.xxapp.main.CrawlerAppMain -10509392 [Thread-0] DEBUG  - Application stop now...
2013-08-02 17:02:01,082 - cn.com.xxapp.distribute.net.executor.DistributeTaskExecutor -10509393 [Thread-0] DEBUG  - Sending terminate msg to scheduler:{4=(0x00000004: nio socket, client, /
2013-08-02 17:02:01,086 - cn.com.xxapp.distribute.net.AbstractIoHandler -10509397 [NioProcessor-2] DEBUG  - Session [(0x00000004: nio socket, client, /192.168.21.153:64712 => /192.168.75.1
2013-08-02 17:02:01,088 - cn.com.xxapp.distribute.net.AbstractIoHandler -10509399 [NioProcessor-2] ERROR  - A exception has occur in sesion[(0x00000004: nio socket, client, /192.168.21.153
java.lang.NoClassDefFoundError: cn/com/xxapp/distribute/net/TaskScheduleProtocol$2
        at cn.com.xxapp.distribute.net.TaskScheduleProtocol.getDecoder(TaskScheduleProtocol.java:98)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.sessionClosed(ProtocolCodecFilter.java:349)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:382)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:47)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:750)
        at org.apache.mina.core.filterchain.IoFilterAdapter.sessionClosed(IoFilterAdapter.java:88)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:382)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionClosed(DefaultIoFilterChain.java:375)
        at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionDestroyed(IoServiceListenerSupport.java:244)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.removeNow(AbstractPollingIoProcessor.java:600)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.removeSessions(AbstractPollingIoProcessor.java:560)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$800(AbstractPollingIoProcessor.java:67)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1132)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
2013-08-02 17:02:01,088 - org.apache.zookeeper.server.NIOServerCnxnFactory -10509399 [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] WARN   - Ignoring unexpected runtime exception
java.nio.channels.CancelledKeyException
        at sun.nio.ch.SelectionKeyImpl.ensureValid(Unknown Source)
        at sun.nio.ch.SelectionKeyImpl.readyOps(Unknown Source)
        at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:187)
        at java.lang.Thread.run(Unknown Source)
2013-08-02 17:02:01,097 - cn.com.xxapp.distribute.zk.ZKServer -10509408 [Thread-6] WARN   - ZkServer was interrupted!
2013-08-02 17:02:01,098 - cn.com.xxapp.distribute.zk.ZkClient -10509409 [Thread-0] DEBUG  - Start close zookeeper client...
2013-08-02 17:02:01,191 - zkerror -10509502 [main-EventThread] ERROR  - Zookeeper客户端与服务端的连接断开,尝试重新连接服务端,Event - WatchedEvent state:Disconnected type:None path:null
2013-08-02 17:02:01,193 - cn.com.xxapp.distribute.zk.ZkClient -10509504 [Thread-0] DEBUG  - Close zookeeper finish
2013-08-02 17:02:01,210 - org.apache.zookeeper.ClientCnxn -10509521 [main-EventThread] ERROR  - Error while calling watcher
java.lang.NoClassDefFoundError: cn/com/xxapp/distribute/zk/ZkClient$ConnectThread
        at cn.com.xxapp.distribute.zk.ZkClient.asynchronousConnect(ZkClient.java:244)
        at cn.com.xxapp.distribute.zk.ZkClient.access$6(ZkClient.java:241)
        at cn.com.xxapp.distribute.zk.ZkClient$ConnectWatcher.process(ZkClient.java:585)
        at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:519)
        at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:495)
Caused by: java.lang.ClassNotFoundException: cn.com.xxapp.distribute.zk.ZkClient$ConnectThread
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 5 more
2013-08-02 17:02:01,211 - cn.com.xxapp.main.CrawlerAppMain -10509522 [Thread-0] DEBUG  - Shutdown thread pool...
2013-08-02 17:02:01,215 - org.apache.zookeeper.server.NIOServerCnxnFactory -10509526 [Thread-0] ERROR  - Thread Thread[Thread-0,5,main] died
java.lang.NoClassDefFoundError: cn/com/xxapp/spider/ThreadPoolFactory
        at cn.com.xxapp.main.CrawlerAppMain$1.run(CrawlerAppMain.java:171)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: cn.com.xxapp.spider.ThreadPoolFactory
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more


加载中
0
情天大圣
情天大圣
缺jar包?
曾杰
曾杰
这些类都是在一个jar里面的,不可能却的
0
曾杰
曾杰
其实在linux上也有这个问题,如果启动了间隔别隔很久停止就不会有这个错误,过一段时间再停就会有错误,难道是把类给卸载了?
0
徐迎龙
徐迎龙
有就有吧,都停了
曾杰
曾杰
问题是中间给异常中断了,后面的正常停止操作下去不了了
0
徐迎龙
徐迎龙
代码里面是不是自定义了classLoader,如果自定义了,那么沿用classLoader是找不到这个jar的
曾杰
曾杰
没定义
返回顶部
顶部