Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

前端 未结 19 2132
清酒与你
清酒与你 2020-12-10 01:32

I\'m trying to display my reports on the browser , but I keep getting this error:

\"enter

相关标签:
19条回答
  • 2020-12-10 01:59

    This can as well be caused by missing/inaccessible Java 'temp' directory. In Font.java, temp files are being created:

    Files.createTempFile("+~JF", ".tmp").toFile();
    

    On one system, the 'temp' dir was missing under Tomcat folder but Java was configured to use it:

    -Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\temp
    

    BTW. first time around, after restarting Tomcat, the service was actually throwing an IOException, but then JasperReports cached something and on subsequent calls the stack trace was exactly as reported here.

    0 讨论(0)
  • 2020-12-10 02:00

    This seems like a Headless mode issue. You need to set the java.awt.headless property to true. That can be done using:

    static {
        System.setProperty("java.awt.headless", "true");
    }
    

    Or, by setting the headless property in your tomcat startup command as -Djava.awt.headless=true

    Also, you can read more on why this is necessary, you can read about the Headless mode here

    0 讨论(0)
  • 2020-12-10 02:00

    In my case problem was with the jdk8 which I was using to build docker image, but after some search I switched to jre. That fixed my bug. I think you can try any image rather than using jdk8.

    0 讨论(0)
  • 2020-12-10 02:01

    This might help ,I had the same error and every other solution didn't work.

    I fixed it by updating to java8.

    0 讨论(0)
  • 2020-12-10 02:04

    I searched several hours for the same issue, and my solution is none of the others mentioned.

    Due to a bad update of my jasper reports version I had multiple versions of the jasperreports jar file on my classpath. Make sure you only have a single jasperreports jar file...

    0 讨论(0)
  • 2020-12-10 02:06

    In my case i was using Arial fonts for this i have configured arial fonts in irfonts.xml which was like below

    <fontFamily name="Arial">
    <normal><![CDATA[fonts/arial.ttf]]> </normal>
    <bold><![CDATA[fonts/arialbd.ttf]]>
    </bold>
    <italic><![CDATA[fonts/ariali.ttf]]>
    </italic>
    <boldItalic><![CDATA[fonts/arialbi.ttf]]>
    </boldItalic>
    <pdfEmbedded><![CDATA[true]]>
    </pdfEmbedded></fontFamily>
    but it should be like :
    <fontFamily name="Arial">
    <normal><![CDATA[fonts/arial.ttf]]><
    /normal>
    <bold><![CDATA[fonts/arialbd.ttf]]></bold>
    <italic><![CDATA[fonts/ariali.ttf]]></italic>
    <boldItalic><!
    [CDATA[fonts/arialbi.ttf]]></boldItalic>
    <pdfEmbedded><!
    [CDATA[true]]></pdfEmbedded>
    </fontFamily>
    so their was a space before the end tag of each tag in above configuration file.
    i fixed it by removing space between them.

    0 讨论(0)
提交回复
热议问题