它是由STS/
Tomcat 7
开发的Spring应用程序。在集成了Jasper report 4.6.0
之后,它总是抛出"OutOfMemoryError: PermGen Space"的异常。然后唯一的方法是重启应用程序。但过了一段时间后,又会再次发生。
这是异常之前的日志:Oct 17, 2012 3:42:27 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 17, 2012 3:42:30 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
这是异常中的一个部分,我在这里发现了一些关于
Jasper
的内容:at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:442)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
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:646)
at org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:240)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:578)
at org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:49)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:655)
以下是当出现这种情况时的几点发现:
The issue can happen on page without any Jasper Report components. It seems the Jasper Report bean is trying to find a tag lib all the time when
a request is processed by the back end and responded to the front end
. Normally from log file I can see above exception will not throw until all back end operations(JPA management) are completeWhen run log4J on debug mode, I see tons of information showing something like parsing/rendering the all components from Jasper template(textfields, pen, box...), there is a small cut from the huge log:
2012-10-17 15:29:12,025 -- DEBUG -- org.apache.commons.digester.Digester.sax -- startElement(http://jasperreports.sourceforge.net/jasperreports,textElement,textElement) 2012-10-17 15:29:12,025 -- DEBUG -- org.apache.commons.digester.Digester -- Pushing body text '' 2012-10-17 15:29:12,025 -- DEBUG -- org.apache.commons.digester.Digester -- New match='jasperReport/summary/band/textField/textElement' 2012-10-17 15:29:12,025 -- DEBUG -- org.apache.commons.digester.Digester -- Fire begin() for FactoryCreateRule[className=net.sf.jasperreports.engine.xml.JRTextElementFactory, attributeName=null, creationFactory=net.sf.jasperreports.engine.xml.JRTextElementFactory@12dc6007] 2012-10-17 15:29:12,025 -- DEBUG -- org.apache.commons.digester.Digester -- [FactoryCreateRule]{jasperReport/summary/band/textField/textElement} New net.sf.jasperreports.engine.design.JRDesignTextField 2012-10-17 15:29:12,025 -- DEBUG -- org.apache.commons.digester.Digester.sax -- ignorableWhitespace()
Still, this log is generated when a request to the page which does not contains any Jasper component.
1.首先问题是:即使应用程序中有一个jasperreport bean,为什么它总是在运行时,即使当前页面没有任何jasper组件也没有进行自动装配。对于这种情况是否有解决/答案?
2.从异常消息中得知“至少扫描了一个JAR以获取TLD,但未包含任何TLD”,应该来自于Tomcat,并且“Tomcat从不包含任何JSTL jar”,因此我认为它无法找到匹配的TLD以解析jasper报告,因此会对所有jar进行全面扫描。如果是这样,那么为什么会有大量来自org.apache.commons.digester.Digester的调试日志实际上似乎正在忙于解析jasper模板?
一般来说,本贴只是尝试找出解决问题的方法,以及找出为什么Jasper在不需要它的地方如此活跃,以及我们如何让Tomcat正确解析模板?
如果太啰嗦,请见谅,并感谢任何提示。
catalina.sh
和JAVA_OPTS="...-XX:MaxPermSize=512m..."中吗? - Dreamer