render jsp 发生了线程阻塞

"http-apr-80-exec-35" daemon prio=6 tid=0x000000000bfd4800 nid=0x2a24 waiting for monitor entry [0x000000003d5ad000]

   java.lang.Thread.State: BLOCKED (on object monitor)

at org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:238)

- waiting to lock <0x00000000e2f2d7d0> (a org.apache.jasper.compiler.TldLocationsCache)

at org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:205)

at org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:618)

at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:409)

at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)

at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)

at org.apache.jasper.compiler.Parser.parse(Parser.java:138)

at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)

at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)

at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)

at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)

- locked <0x00000000e4da08b8> (a org.apache.jasper.servlet.JspServletWrapper)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)

at com.jfinal.render.JspRender.render(JspRender.java:67)

at com.jfinal.core.ActionHandler.handle(ActionHandler.java:99)

at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)



下边是阻塞线程


"http-apr-80-exec-254" daemon prio=6 tid=0x0000000009529800 nid=0x6468 waiting for monitor entry [0x000000006923d000]

   java.lang.Thread.State: BLOCKED (on object monitor)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)

- waiting to lock <0x00000000e4da08b8> (a org.apache.jasper.servlet.JspServletWrapper)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)

at com.jfinal.render.JspRender.render(JspRender.java:67)

at com.jfinal.core.ActionHandler.handle(ActionHandler.java:99)

at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at com.jdxweb.common.session.SessionFilter.doFilter(SessionFilter.java:34)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

我用域名访问那个url地址显示一直等待,但是用ip访问就能顺利的打开

感觉非常奇怪


"cron4j::scheduler[6c83b8156e7b52bf4ec6ca370000016028a2726570e068d9]::executor[6c83b8156e7b52bf26060edb000001602a7c09001c815e83]" daemon prio=6 tid=0x0000000009534800 nid=0x9a68 waiting for monitor entry [0x000000006a42f000]

   java.lang.Thread.State: BLOCKED (on object monitor)

at java.io.PrintStream.println(PrintStream.java:823)

- waiting to lock <0x00000000e1a91df0> (a java.io.PrintStream)

at org.apache.tomcat.util.log.SystemLogHandler.println(SystemLogHandler.java:269)

at com.Task.ZsyRechargeAPITask.run(ZsyRechargeAPITask.java:12)

at it.sauronsoftware.cron4j.RunnableTask.execute(Unknown Source)

at it.sauronsoftware.cron4j.TaskExecutor$Runner.run(Unknown Source)

at java.lang.Thread.run(Thread.java:745)


   Locked ownable synchronizers:

- None

还有一个system.out.print阻塞的线程





评论区

快乐的蹦豆子

2017-12-06 16:08

最终都在等这个
"http-apr-80-exec-12" daemon prio=6 tid=0x0000000009b16000 nid=0xc8a4 runnable [0x0000000031c1c000]
java.lang.Thread.State: RUNNABLE
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:345)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
- locked <0x00000000e1a91730> (a java.io.BufferedOutputStream)
at java.io.PrintStream.write(PrintStream.java:480)
- locked <0x00000000e1a91710> (a java.io.PrintStream)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
- locked <0x00000000e1b03068> (a java.io.OutputStreamWriter)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.util.logging.StreamHandler.flush(StreamHandler.java:242)
- locked <0x00000000e1b02fa8> (a java.util.logging.ConsoleHandler)
at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:106)
at java.util.logging.Logger.log(Logger.java:616)
at java.util.logging.Logger.doLog(Logger.java:641)
at java.util.logging.Logger.logp(Logger.java:757)
at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:183)
at org.apache.juli.logging.DirectJDKLog.info(DirectJDKLog.java:126)
at org.apache.jasper.compiler.TldLocationsCache.tldScanJar(TldLocationsCache.java:487)
at org.apache.jasper.compiler.TldLocationsCache.access$100(TldLocationsCache.java:79)
at org.apache.jasper.compiler.TldLocationsCache$TldJarScannerCallback.scan(TldLocationsCache.java:261)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:178)
at org.apache.jasper.compiler.TldLocationsCache.init(TldLocationsCache.java:245)
- locked <0x00000000e2f2d7d0> (a org.apache.jasper.compiler.TldLocationsCache)
at org.apache.jasper.compiler.TldLocationsCache.getLocation(TldLocationsCache.java:205)
at org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:618)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:409)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
- locked <0x00000000e4e4a568> (a org.apache.jasper.servlet.JspServletWrapper)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
at com.jfinal.render.JspRender.render(JspRender.java:67)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:99)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.jdxweb.common.session.SessionFilter.doFilter(SessionFilter.java:34)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
- locked <0x00000000e4f15fe8> (a org.apache.tomcat.util.net.AprEndpoint$AprSocketWrapper)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

JFinal

2017-12-06 16:18

光看异常很难看出什么来,java 代码是怎样的?

此外,如果阻塞发生成 jsp 模板之中,这个 jfinal 是无法干预到的,因为 jfinal 仅仅只是将请求转发给 jsp 模板,并未做任何多余的动作,这个可以看一下 JspRender 源代码,只有一行核心代码:
request.getRequestDispatcher(jspFile).forward(request, response);

JFinal

2017-12-06 16:19

在异常中看到这个字眼: cron4j::scheduler, 难道你是在独立的线程中去使用 JSP 渲染? 这个很难找到合理的场景

快乐的蹦豆子

2017-12-06 18:33

import java.util.Date;

import com.jfinal.plugin.cron4j.ITask;

public class ZsyRechargeAPITask implements ITask{
public static int para = 1;
public void run() {
// 这里放被执行的调试任务代码
para++;
System.out.println(new Date());
System.out.println(para);
try {
Thread.sleep(60*60*60);
System.out.println("handler");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void stop() {
// 这里的代码会在 task 被关闭前调用
System.out.println("stop");
}

}

这是那个任务代码,是不是因为sleep 导致的没有释放锁

我最后找到两个锁地方
第一个
"cron4j::scheduler[6c83b8156e7b52bf251cee300000016028a28cef713e5a39]::executor[6c83b8156e7b52bf379fd2410000016028a39f611b8fb1bc]" daemon prio=6 tid=0x0000000008d52000 nid=0x5eb4 runnable [0x000000001117e000]
java.lang.Thread.State: RUNNABLE
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:345)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
- locked <0x00000000e1a91e10> (a java.io.BufferedOutputStream)


第二个
"http-apr-80-exec-12" daemon prio=6 tid=0x0000000009b16000 nid=0xc8a4 runnable [0x0000000031c1c000]
java.lang.Thread.State: RUNNABLE
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:345)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122)
- locked <0x00000000e1a91730> (a java.io.BufferedOutputStream)
at java.io.PrintStream.write(PrintStream.java:480)
- locked <0x00000000e1a91710> (a java.io.PrintStream)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
- locked <0x00000000e1b03068> (a java.io.OutputStreamWriter)



at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:345)

最后都是这个地方锁住的,我看了源码这个地方是synchronized的。

热门反馈

扫码入社