tags:

views:

124

answers:

4

The web app occasionally get hang for about 30 seconds when user request a web page, the server's CPU and memory usage are ok, and the jstack shows:

"http-9999-3" daemon prio=6 tid=0x552f3400 nid=0xf40 runnable [0x578fc000]
   java.lang.Thread.State: RUNNABLE
    at org.eclipse.jdt.internal.compiler.parser.Parser.getTypeReference(Parser.java:8354)
    at org.eclipse.jdt.internal.compiler.parser.Parser.consumeClassHeaderExtends(Parser.java:2125)
    at org.eclipse.jdt.internal.compiler.parser.Parser.consumeRule(Parser.java:5107)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9020)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9251)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9208)
    at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:7864)
    at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:587)
    at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:357)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:371)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:413)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    - locked <0x10a75fc0> (a org.apache.jasper.servlet.JspServletWrapper)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
    ......

seems it's related with some jsp files, how to find the root cause? thanks.

+1  A: 

If the web page hangs it seems like the Garbage Collector in Java has entered the scene. Try some JVM options like the one found here or more complete here.

I would start with the parallel garbage collector by enabling it with

-XX:-UseParallelGC

If the problem has really to do with your JSPs than the reason is that every JSP has to be compiled for the first time it is used. If you have very complex JSPs (maybe which include several other JSPs) this might take some time.

Daniel
A: 

Try to precompile JSP pages.

Guillaume
A: 

You need to find WHERE that time goes, as that is important to fix it.

One example could be a negative DNS lookup needing to time out. Another could be a locked file in the file system.

If you use Sun Java 6, then consider using jvisualvm in the JDK to attach to the running process and use the profiler to identify where the time is spent. If jvisualvm is not an option, then consider using a commercial profiler in trial mode to get this information.

Thorbjørn Ravn Andersen
A: 

Agree with Daniel. This sounds like the Garbage Collector running. In addition to his suggestion have a look at -Xms and -Xmx.

JCW