Tomcat没有回应

时间:2016-06-06 14:01:50

标签: java multithreading tomcat jcr

我负责部署Java应用程序。我的问题是经过一个小时的tomcat停止进程请求。

curl localhost:8080没有回答。

Tomcat进程仍处于活动状态,RAM和服务器的平均负载均正常。在我的应用程序中,我没有在tomcat的日志中出错。

我使用kill -3 tomcat_pid做了一个Thread Dump。 几乎所有线程都处于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)

1 个答案:

答案 0 :(得分:0)

这是由于其中一个线程被阻塞(这可能是由于网络或数据库问题所致),最重要的是,多个请求从您的Web服务器排队到app(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)

可以通过重新启动服务器来解决此问题,因为它会清除所有队列。