StreamResource - Multiple Threads

Hi!

I have the following Problem: In firefox when I click on the link I connected with the StreamResource

StreamResource.StreamSource pdfsource = new StreamResource.StreamSource()
            {

                @Override
                public InputStream getStream()
                {
                    byte[] b = null;
                    try
                    {
                        String current_sql = generateSqlQuery(sql, (Date) fromField.getValue(), (Date) toField.getValue());
                        QueryContainer sql_container = (QueryContainer) sqlTable.getContainerDataSource();
                        JasperPrint jp = generateJasperPrint(tableName, sql_container, current_sql, iconString, false);
                        b = JasperExportManager.exportReportToPdf(jp);
                        //b = JasperRunManager.runReportToPdf(getClass().getClassLoader().getResourceAsStream("test.jp"));
                    } catch (JRException ex)
                    {
                        System.out.println(ex.getMessage());
                        //Logger.getLogger(TokenForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    //throw new UnsupportedOperationException("Not supported yet.");
                    return new ByteArrayInputStream(b);
                }
            };

I get 2 threads: one when clicking on “Save As” from the context menu, one if I click to save then.
Depending on how the two threads perform, it sometimes works to create the Reports, sometimes not.

So there are 2 questions:

  1. Why do there appear two threads?
  2. Why are the two threads not independent from each other?

During the generation I get the following outputs:


INFO: generating JasperReport
INFO: generating JasperReport
WARNUNG: Parameter "REPORT_LOCALE" already registered, skipping this one: de_AT
WARNUNG: Parameter "JASPER_REPORT" already registered, skipping this one: net.sf.jasperreports.engine.JasperReport@1eb7a7e

This indicates that when the second report is generated, there are some parameters already initialized from the first one, even though the threads are not the same.

Please help, I’m working for 24 hours on that…
Chris
:wacko: