Jump to content
We've recently updated our Privacy Statement, available here ×

Getting an ExceptionInInitializerError on JREBaseFiller


Recommended Posts

Hi all,

I've developed a java application to create a pdf report. My app works fine on my local machine (Windows 7) but when I launch on a remote server(Windows Server 2008 R2 standard) i receive an absurde exception:
 

Exception in thread "main" java.lang.ExceptionInInitializerError        at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:108)        at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:69)        at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)        at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:200)        at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:215)        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:115)        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:583)        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:929)        at com.test.PdfWriter.writePdfFromList(PdfWriter.java:85)Exception: net.sf.jasperreports.engine.JRRuntimeException thrown from the UncaughtExceptionHandler in thread "main"[/code]


I'm using jasper reports 6.2.2 and jdk 1.7.25.

This is the method I've devoloped to write the pdf:

   public static void writePdfFromList(final LoggingSettings loggingSettings,            final List<Object> listToWrite,            final String jasperDataSourceParamName, final String jasperFile,            final String pdfOutputFile) throws CustomException {        LogManagement lm = new LogManagement(loggingSettings, CLASS_NAME);        try {            /* Convert List to JRBeanCollectionDataSource */            lm.debug(new StringBuilder("Defining JRBeanCollectionDataSource")                    .append(" that will store the array list"));            JRBeanCollectionDataSource itemsJRBean =                    new JRBeanCollectionDataSource(listToWrite, false);            /* Map to hold Jasper report Parameters */            lm.debug(new StringBuilder("Defining map to hold")                    .append(" Jasper report Parameters"));            Map<String, Object> parameters = new HashMap<String, Object>();            parameters.put(jasperDataSourceParamName, itemsJRBean);            /*             * Using compiled version(.jasper) of Jasper report to generate             * PDF             */            lm.debug(new StringBuilder("Getting JasperPrint")            .append(" to the fill report"));            JasperPrint jasperPrint =                    JasperFillManager.fillReport(jasperFile, parameters,                            new JREmptyDataSource());            /* outputStream to create PDF */            lm.debug(new StringBuilder("Defining the outputStream")            .append(" to create PDF"));            OutputStream outputStream =                    new FileOutputStream(new File(pdfOutputFile));            /* Write content to PDF file */            lm.info(new StringBuilder("Write content to PDF file"));            JasperExportManager.exportReportToPdfStream(jasperPrint,                    outputStream);        } catch (Exception e) {            // TODO Auto-generated catch block            throw lm.error(e);        }    }[/code]



Searching on the web and on the community I found other topics that talks about using jasper javaflow.
I've tried to use the jasper report javaflow but nothing is changed, I still receive same error.

I'm going crazy because I'm not able to understand what is the problem, on my local machine it works, why it doesn't works on the remote server??
Colud you please someone help me or give me some suggestion on how I can solve it??

Thanks in advance

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

One thing that you can try is to enable AWT headless mode on the server machine by adding -Djava.awt.headless=true to the Java arguments.

If that doesn't get rid of the error, try getting the latest 6.3.0 snapshot from https://jaspersoft.artifactoryonline.com/jaspersoft/repo/net/sf/jasperreports/jasperreports/6.3.0-SNAPSHOT/ and test your application with that.  The error might still occur, but at least it should log the original exception (which is currently obscured).

Regards,

Lucian

Link to comment
Share on other sites

Hi Lucian

I think I've finally found the error, it was related to maven. In my project I've the jasper report library and also a jar with some custom fonts (created with jasper studio).

Both jar have the same jasperreport_extension.properties file. When the maven shade plugin builds the final jar overwrites one of the two properties file, the most important, the one inside the jasper report library. So probably when I launch the app, jasper finds the properties file but at the inside there aren't the propeties he needs to work correctly and this generates that uncaught exception.

I solved it by adding this configuration inside the maven shade plugin:

<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>jasperreports_extension.properties</resource></transformer>[/code]

This tranformer appends the content of one properties file to the other one.

I don't know, if in the future it can be helpful add in the jasper report library the exception to handle when some porperties are missing.

Thanks for the help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...