Friendlyghost89
Friendlyghost89

Reputation: 349

Report will not load from netbeans JasperReports

Hello to all whom read this....

I have been bashing my head against the wall and desk for a few days now.... I am creating a report with JasperReports in a netbeans project. I have no clue what happened but one moment it was working and the next I had 2 WARNings pop up and now the Reports window (Screen Printout) and the PDF printout will not load unless the code is ran from within the Development environment.

Here are the warnings: log4j:WARN No appenders could be found for logger (net.sf.jasperreports.engine.xml.JRXmlDigesterFactory). log4j:WARN Please initialize the log4j system properly.

The warnings are thrown by this line of code that I use to compile the report:

JasperReport jasperReport = JasperCompileManager.compileReport("C:/Report/report1.jrxml");

The whole block of code that is used for compiling and generating the report is as follows:

public void Print_File() {
    try {
        String parameter = LoadNum_Text.getText();
        String RecordPath = "C:/Report/Created/LoadSheet/";

        String name = RecordPath + parameter;
        String destinationFile = name + ".pdf";

        Map param = new HashMap();

        param.put("Load_Number", parameter);

        con = DriverManager.getConnection(host, uName, uPass);

        String sql = "SELECT * FROM Load_Sheet";

        JasperReport jasperReport = JasperCompileManager.compileReport("C:/Report/report1.jrxml");
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, param, con);
        JasperExportManager.exportReportToPdfFile(jasperPrint, destinationFile);//export dynamic file name
        //con.close();
        try {
            JasperViewer visor = new JasperViewer(jasperPrint, false);
            visor.setVisible(true);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

Also my previous versions of the code have the same issue now as i have tried rolling back to them and I also tried an old version of a (what used to be) working report1.jrxml file.

I have also tried a different MYSQL server that I had running else where just as a try to see if that was a potential issue, but still had the same end result.

I have tried just importing the libraries from IReport itself (the program i used to generate the report), but also no avail.

I have also downloaded and tried the source for JasperReport4.5.0 as well as 3.0.1 also with even less avail...

Any help that you could provide i would greatly appreciate it...

Upvotes: 2

Views: 9132

Answers (3)

Jyoti
Jyoti

Reputation: 1

We have faced similar issues while exporting the report through Jasper, In our application we have spring-4.3.2.jar version and jasperreports-5.6.1.jar.

Resolution is simply to delete these constants from chartConstantsBean.xml, they couldn't be used anyway.

chartConstantsBean.xml is in jasperreports-chart-themes-5.0.0.jar.

We have removed this and it is working without any error or warning.

Upvotes: 0

Jay kumar
Jay kumar

Reputation: 1

add

spring.jar file
spring-core-3.2.4.RELEASE
swingx-2007_10_07

It will work fine after giving some warning like---

log4j:WARN No appenders could be found for logger (net.sf.jasperreports.engine.xml.JRXmlDigesterFactory).
log4j:WARN Please initialize the log4j system properly.

Upvotes: 0

Tony Rad
Tony Rad

Reputation: 2509

add the following log4j.xml file in your classpath:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
    <appender name="CA" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n" />
        </layout>
    </appender>
    <appender name="FA" class="org.apache.log4j.FileAppender">
        <param name="File" value="myReport.log"/>
        <param name="Threshold" value="ALL"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n" />
        </layout>
    </appender>
    <root>
        <level value="ALL" />
        <appender-ref ref="CA" />
        <appender-ref ref="FA" />
    </root>
</log4j:configuration>

this should solve the log4j.xml WARN and give you more info about what happens (look at myReport.log and eventually post it here if you still have issues ) .


Hi Erik, I looked at myReport.log and I found the following (all similar) errors:

5072 [AWT-EventQueue-0] DEBUG org.springframework.beans.factory.xml.XmlBeanFactory  - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'titleBaseFontSize': Invocation of init method failed; nested exception is 
java.lang.NoSuchFieldException: TITLE_BASEFONT_SIZE
5315 [AWT-EventQueue-0] DEBUG org.springframework.beans.factory.xml.XmlBeanFactory  - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'subtitleBaseFontSize': Invocation of init method failed; nested exception is 
java.lang.NoSuchFieldException: SUBTITLE_BASEFONT_SIZE
5610 [AWT-EventQueue-0] DEBUG org.springframework.beans.factory.xml.XmlBeanFactory  - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'legendBaseFontSize': Invocation of init method failed; nested exception is java.lang.NoSuchFieldException: LEGEND_BASEFONT_SIZE
5991 [AWT-EventQueue-0] DEBUG org.springframework.beans.factory.xml.XmlBeanFactory  - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'axisLabelFontSize': Invocation of init method failed; nested exception is java.lang.NoSuchFieldException: AXIS_LABEL_FONT_SIZE
6041 [AWT-EventQueue-0] DEBUG org.springframework.beans.factory.xml.XmlBeanFactory  - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'axisTickLabelFontSize': Invocation of init method failed; nested exception is java.lang.NoSuchFieldException: AXIS_TICK_LABEL_FONT_SIZE
.....
.....
.....

so a lot of java.lang.NoSuchFieldException (which means that the Java runtime invoke of a class cannot find the method, which is quite usual if the jasper report designer version is different from the runtime). My suspect is that the dev env is different from your runtime environment, so please double check if the jasper reports version is the same in the two environments.

Another test that you could do is to confront the myReport.log of the dev env with the myReport.log of the other env and see if you have the java.lang.NoSuchFieldException exception in both. (and in general what are the differences). If you find that they are different (for example you don't catch the java.lang.NoSuchFieldException) then the suspect is almost a fact.

regards

Upvotes: 1

Related Questions