Tomcat 没有响应
Posted
技术标签:
【中文标题】Tomcat 没有响应【英文标题】:Tomcat does not respond 【发布时间】:2016-10-06 04:24:13 【问题描述】:我负责部署 Java 应用程序。我的问题是一个小时后tomcat停止进程请求。
curl localhost:8080 没有应答。
Tomcat 进程还活着,并且服务器的 RAM 和平均负载都正常。我的应用程序中的tomcat日志也没有错误。
我使用 kill -3 tomcat_pid 进行了线程转储。 几乎所有线程都处于 WAITING 或 TIMED_WAITING 状态。
我使用 Tomcat v7.0.56。该应用程序使用 JackRabbit JCR 作为数据源。
如何调试我的服务器?
编辑:
这是一些线程堆栈示例: 大多数“http-bio-8080-exec-N”线程看起来像这样:
"http-bio-8080-exec-16" daemon prio=10 tid=0x00007f0cacfc1000 nid=0x56b6 waiting on condition [0x00007f0c62abc000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007f574af30> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
还有参考 JCR 和 Derby 数据库:
"derby.antiGC" daemon prio=10 tid=0x00007f0ca0953000 nid=0x5610 in Object.wait() [0x00007f0ca8d11000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007f7543aa8> (a org.apache.derby.impl.services.monitor.AntiGC)
at java.lang.Object.wait(Object.java:503)
at org.apache.derby.impl.services.monitor.AntiGC.run(Unknown Source)
- locked <0x00000007f7543aa8> (a org.apache.derby.impl.services.monitor.AntiGC)
at java.lang.Thread.run(Thread.java:745)
这里:
"jackrabbit-pool-1" daemon prio=10 tid=0x00007f0ca08c7800 nid=0x560f waiting on condition [0x00007f0ca8d92000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007fa29ccb0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1085)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
【问题讨论】:
WAITING=A thread that is waiting indefinitely for another thread to perform a particular action is in this state. \n\n TIMED_WAITING=A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
你的线程还在等什么?
在转储中打印一些线程堆栈
感谢重播!我编辑了我的答案。
似乎与 derby 数据库连接相关的问题正在停止整个应用程序。检查你是否有这些德比版本issues.apache.org/jira/browse/DERBY-2905
【参考方案1】:
这将是由于其中一个线程被阻塞(这可能是由于网络或数据库问题),并且最重要的是,多个请求从您的网络服务器排队到应用程序(tomcat)。
当你遇到这个错误时,你会看到很多类似下面的错误,并且在这种情况下重新启动 tomcat 服务将无济于事,因为它可能会被缓存。
"Thread-14" #83 daemon prio=5 os_prio=0 tid=0x00007f702c017000 nid=0x3830 waiting on condition [0x00007f707125e000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at com.tridion.licensing.events.LicenseTracker.run(LicenseTracker.java:91)
at java.lang.Thread.run(Thread.java:748)
和
"Thread-14" #83 daemon prio=5 os_prio=0 tid=0x00007f702c017000 nid=0x3830 waiting on condition [0x00007f707125e000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at com.tridion.licensing.events.LicenseTracker.run(LicenseTracker.java:91)
at java.lang.Thread.run(Thread.java:748)
这可以通过重新启动服务器来解决,因为它会清除所有队列。
【讨论】:
以上是关于Tomcat 没有响应的主要内容,如果未能解决你的问题,请参考以下文章