Issue with external styles: getting StackOverflowE

2019-07-25 09:17发布

问题:

So I am in the process of upgrading jasper reports off of a very old version. This was from 3.7.6 to 6.3.0, so yeah, lots of changes. For the most part, it wasn't as bad as I expected it to be. Needed to update some deprecated stuff around file resolvers and exporters, but most everything works and visual layout of reports is the same.

The only problem that I've had and have been unable to solve is around setting default styles. We do this in a number of reports and is giving me an error that I cannot make sense of.

<?xml version="1.0"?>
    <!DOCTYPE jasperTemplate
            PUBLIC "-//JasperReports//DTD Template//EN"
            "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

    <jasperTemplate>

        <style name="gothamBase" fontName="Monospaced" forecolor="#5d5c5c" vAlign="Top"></style>

        <style name="gothamMedium" style="gothamBase" fontSize="12" isDefault="true" ></style>

    </jasperTemplate>

So this is an example of style that is giving me issues. When we attempt to compile a report that references this, I get:

threw exception [Handler processing failed; nested exception is java.lang.StackOverflowError] with root cause
java.lang.StackOverflowError
    at net.sf.jasperreports.engine.base.JRBaseStyle.getStyle(JRBaseStyle.java:338)
    at net.sf.jasperreports.engine.util.StyleResolver.getBaseStyle(StyleResolver.java:109)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1191)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)
    at net.sf.jasperreports.engine.util.StyleResolver.getFontName(StyleResolver.java:1194)
    at net.sf.jasperreports.engine.base.JRBaseStyle.getFontName(JRBaseStyle.java:594)

To exclude other factors, I gutted the report so that it was empty with just a reference to the template that had the above style. I removed all other styles from the template file.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="title" pageWidth="792" pageHeight="612" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="792" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
    <template><![CDATA["styles.jrtx"]]></template>

</jasperReport>

Still have the issue even after narrowing it down to this. For some reason it does not like me setting a default style when that style also references a parent style. But looking at the jasper documentation, what I'm doing here is valid.

I found this http://community.jaspersoft.com/questions/535452/javalangstackoverflowerror, which had a similar error. But we are not using javaflow. Just to be sure I've added that change to log4j so that javaflow is not on debug, that didn't change anything. Also tried excluding javaflow from our pom, no luck either.

Any help?