Jump to content
  • jasperreports 3.6.1, subreports & too many open files


    agharta
    Assigned User teodord
    CategoryBug report
    PriorityHigh
    ReproducibilityAlways
    ResolutionNo Change Required
    SeverityMajor
    StatusClosed

    Hi all,

    I don't known if it is a bug.

     

    I've a report with 10 subreports:

    subreport expression class is java.io.InputStream and the subreport expression is something like getClass().getClassLoader().getResourceAsStream("the/report/classpath/report.jasper")

     

    All works fine.

     

    My servlet that load the print generates correctly the file.

     

     

     

    example:

     

    try {

    InputStream is = getClass().getClassLoader().getResourceAsStream(

    "report/report.jasper");

     

    log.debug("Generate Report....");

     

    JasperRunManager.runReportToPdfStream(

    is,

    res.getOutputStream(),

    parameterMap,

    conn);

     

    log.debug("Report Created! Send it to output stream...");

    } catch (Exception e) {

    e.printStackTrace();

    log.error(e);

    } finally {

    log.debug("Closing connection..");

    conn.close();

    log.debug("Connection successfully closed! FINISH!");

    }

     

     

    And all still works fine.

     

    So, the problem: under unix (linux) machines the subreports (not the main report) won't be closed!!!

     

    The problem is that, if i have a report with 10 subreport per detail row and, if i have a dataset with 1000 rows, the open files goes to 10000!!!!!

     

    The application catch to

    GRAVE: Socket accept failed

    java.net.SocketException: Too many open files

    at java.net.PlainSocketImpl.socketAccept(Native Method)

    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390)

    at java.net.ServerSocket.implAccept(ServerSocket.java:453)

    at java.net.ServerSocket.accept(ServerSocket.java:421)

    at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)

    at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:317)

    at java.lang.Thread.run(Thread.java:619)

    5-nov-2009 10.23.19 org.apache.tomcat.util.net.JIoEndpoint$Acceptor run

     

     

     

    So, if i type a lsof | grep "jasper" from console, i'll get something like this:

    java 5577 tomcat 245r REG 9,1 15769 63052 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/selectedDietFromPatientIdAndDate.jasper

    java 5577 tomcat 246r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 247r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 248r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 249r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 250r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 251r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 252r REG 9,1 15769 63052 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/selectedDietFromPatientIdAndDate.jasper

    java 5577 tomcat 253r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 254r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 255r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 256r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 257r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 258r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 259r REG 9,1 15769 63052 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/selectedDietFromPatientIdAndDate.jasper

    java 5577 tomcat 260r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 261r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 262r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 263r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 264r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 265r REG 9,1 16252 63048 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/fasts.jasper

    java 5577 tomcat 266r REG 9,1 15769 63052 /usr/java/apache-tomcat-6.0.20/work/Catalina/localhost/gr/WEB-INF/classes/report/admissions/selectedDietFromPatientIdAndDate.jasper

     

     

    ........repeated about 1200 times.....

     

     

    So, if i search if the main report (report.jasper), i don't find anything! The main report is not open, but the child reports yes.

     

     

    I've increased the ulimit of open files to 1.000.000, i hope that it can be engouth.

     

    The strange thing is that if i force a garbage collection (Runnable.getRunnable().gc()), all opened .jasper files will be closed.

     

     

    Any ideas?

     

    Thanks,

     

    Agharta

     



    User Feedback

    Recommended Comments

    Hi,

     

    You should not reference subreport templates using that expression of yours. You should simply use a String expression for the subreport location, using the relative location within classpath of the subreport template.

    This way, JR will load the subreport resource for you and also make sure the input stream is closed after that. In addition, JR will also cache the subreport templates and load them only once, if the expression points to the same subreport template repeatedly, during the master report filling.

     

    "the/report/classpath/report.jasper"

     

    If this does not work for you, feel free to reopen this tracker, but I'm closing it for now as there is clearly no problem with JR. You are using it in a wrong way.

     

    I hope this helps.

    Teodor

     

    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...