在两台服务器上,我现在最近开始遇到一个问题 - 使用Tomcat,NIO连接器和Java 7,其中一个线程现在已经开始挂在一个不可能的位置。有问题的线程都是http请求处理程序,并且为各种目的配置了过滤器 - 似乎是一个问题的地方是我们正在对用户进行基本IP检查。我已经复制了下面似乎有问题的堆栈跟踪(删除了非基本数据),以及exec-7显然被卡住的代码行。
"http-80-exec-7" daemon prio=10 tid=0x0000000000e89000 nid=0x722a in Object.wait() [0x00007f7438ab5000]
java.lang.Thread.State: RUNNABLE
at com.web.utilities.server.Entity.makeIdentifierMultiLingual(Entity.java:5469)
[[ ... no locks or anything here, just lots of irrelevant depth ... ]]
at com.web.utilities.server.Entity.find(Entity.java:1953)
at com.web.portal.entities.TypeRegistry.theTypeRegistry(TypeRegistry.java:118)
- locked <0x0000000361518798> (a java.lang.Class for com.web.portal.entities.TypeRegistry)
at com.web.portal.entities.TypeRegistry.theTypeRegistryReverse(TypeRegistry.java:206)
- locked <0x0000000361518798> (a java.lang.Class for com.web.portal.entities.TypeRegistry)
at com.web.portal.entities.TypeEncoding.theTypeEncoding(TypeEncoding.java:2355)
[[ request stuff ]]
at java.lang.Thread.run(Thread.java:722)
"http-80-exec-4" daemon prio=10 tid=0x0000000000ebc800 nid=0x7225 waiting for monitor entry [0x00007f7438fba000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.web.portal.entities.TypeRegistry.theTypeRegistryReverse(TypeRegistry.java:203)
- waiting to lock <0x0000000361518798> (a java.lang.Class for com.web.portal.entities.TypeRegistry)
at com.web.portal.entities.TypeEncoding.theTypeEncoding(TypeEncoding.java:2355)
[[ ... no locks or anything here, just lots of irrelevant depth ... ]]
at com.web.portal.SiteController.init(SiteController.java:5165)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
- locked <0x0000000324a28358> (a org.apache.catalina.core.StandardWrapper)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
- locked <0x0000000324a28358> (a org.apache.catalina.core.StandardWrapper)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:883)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:722)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
我没有得到的是线程如何挂在makeIdentifierMultiLingual
半小时或更长时间 - 总是那条线上没有任何wait
代码 - 那么怎么办?它认为它在Object.wait
?如何可能如何同时拥有RUNNABLE
和Object.wait
的帖子?以下是有问题的一行:
private String makeIdentifierMultiLingual(String identifier) {
try {
==> if (SiteTranslator.getTargetLanguage() != SiteTranslator.getDefaultLanguage()) {
现在这两个方法都访问ThreadLocal变量,但堆栈跟踪并没有指向那些代码行。我一直想知道堆栈跟踪是否有些错误,但我不知道它们是如何使用标准jstack
可执行文件(在Ubuntu服务器上)创建的。据我所知,这里的根本问题是,我有一个线程基本上会导致死锁,因为他在持有一个相当常见的锁/类的同时永远沉睡,同时报告自己并且似乎是RUNNABLE - 是否存在更好还是更深入地分析这个问题?