Vaadin + jasperreports

I Have this code:

[code]
MenuBar.Command imprimirDashboardCommand = new MenuBar.Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {

            imprimirDashboard();
        }

    };
    MenuItem item = menuImprimir.addItem("",FontAwesome.PRINT, null);
    menuImprimir.setAutoOpen(false);
    item.addItem("Dashboard", imprimirDashboardCommand);

[/code]and my imprimirDashboard

private void imprimirDashboard(){
        try{
            Dashboard dashboard = new Dashboard();
            dashboard.setTotalEntradas(this.vlTotalEntradasRelatorio);
            dashboard.setTotalSaidas(this.vlTotalSaidasRelatorio);
            dashboard.setTotalLiquido(this.vlTotalLiquidoRelatorio);
            dashboard.setEntradas(entradasContainer.getItemIds());
            dashboard.setOutrasEntradas(outrasEntradasContainer.getItemIds());
            dashboard.setSaidas(saidasContainer.getItemIds());
            dashboard.setOutrasSaidas(outrasSaidasContainer.getItemIds());
            dashboard.setCustas(custasContainer.getItemIds());
            dashboard.setMovimentacaos(movimentacaosContainer.getItemIds());
            
            JsonDataSource jsonDS = new JsonDataSource(new ByteArrayInputStream(jsonConverter.writeValueAsString(dashboard).getBytes(StandardCharsets.UTF_8)));
            
            try {
                
            
                Resource resource = resourceLoader.getResource(resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/DashboardCaixa.jrxml");
                 
                Map<String, Object> parametros = new HashMap<>();
                parametros.put("SUBREPORT_DIR",resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/");
                JasperDesign jasperDesign = JRXmlLoader.load(resource.getInputStream());                
                JasperReport jasperReport  = JasperCompileManager.compileReport(jasperDesign);
                jsonDS.setDatePattern("yyyy-MM-dd HH:mm:ss");
                jsonDS.setNumberPattern("#,##0.##");
                jsonDS.setLocale(Locale.US);

                  
                   StreamResource.StreamSource source = new StreamResource.StreamSource() {
                    public InputStream getStream() {
                            byte[] b = null;
                            try{                                
                                    b = JasperRunManager.runReportToPdf(jasperReport, parametros, jsonDS);
                                
                            } catch (Exception ex) {
                                ex.printStackTrace();

                            }
                            return new ByteArrayInputStream(b);    
                    }
                };
                 StreamResource resourcesReport = new StreamResource(source, "myreport_" + System.currentTimeMillis() + ".pdf");
                 BrowserWindowOpener opener =
                         new BrowserWindowOpener(resourcesReport);
                 //FIXME fazer abrir janela automaticamente
                 opener.extend(menuImprimir);
                
            } catch (Exception e) {
                e.printStackTrace();
            }
            
        }catch(Exception e){
            e.printStackTrace();
        }
    }

So in this case, I need to click 2 times in menu Dashboard, how can I open a new window, in the first click? and this is the correct way to show one report with vaadin?

tks

Hi Fabio,
in your case the problem is that the BroserWindowOpener adds a click listener on client side when it extends a component, so the window.open function is called next time you click the element.

You can create an instance of BroserWindowOpener and extend the menubar outside your command listener, and then in your listener you can simply call BroserWindowOpener.setResource(…).

Howere this will not work because BroserWindowOpener click listener on client side will be executed before your server side command listener.

A tricky way to achieve your result could be to extend BrowserWindowOpenerConnector so that window open is triggered on state change instead of on click;
this way click on menu item will fire your command listener, the command listener will set the resource on browser window opener and then,
at the end of the request, the BrowserWindowOpenerConnector should be notified of change of state and will open window.
Of course with this solution you need to recompile your widgetset.

Here is some sample code

public class MyOpenerState extends BrowserWindowOpenerState {
    // Only needed to ensure change state
    public long lastUpdated;
}

public class MyWindowOpener extends BrowserWindowOpener {

    @Override
    protected void setResource(String key, Resource resource) {
        super.setResource(key, resource);
        // forces state change when resource is set
        getState().lastUpdated = Instant.now().toEpochMilli();
    }

    @Override
    protected MyOpenerState getState() {
        return (MyOpenerState)super.getState();
    }
}

@Connect(MyWindowOpener.class)
public class MyWindowOpenerConnector extends BrowserWindowOpenerConnector {

    @Override
    public void onClick(ClickEvent event) {
        // Do nothing on click
    }

    @OnStateChange("lastUpdated")
    private void onLastUpdateChanged() {
        // open window
        super.onClick(null);
    }

    @Override
    public MyOpenerState getState() {
        return (MyOpenerState) super.getState();
    }
}

And then in your UI

MenuBar menuBar = new MenuBar();

MyWindowOpener opener = new MyWindowOpener((Resource) null);
opener.extend(menuBar);

menuBar.addItem("Print A", (MenuBar.Command) selectedItem -> {
    StreamResource res = doAllYouNeedToCreateTheResource();
    res.setCacheTime(0);
    opener.setResource(res);
});
 

HTH
Marco

Marco.

With my example when I try to run in my client server I got nullpointer exception in line

return new ByteArrayInputStream(b); After generate rel, I click again in button to download the rel, in dev works fine, but in prod dont. have some problem with session or something else?

tks

For the nullpointer the problem seems to be in jasper report generation.
Have you checked logs on customer server to see if there are exceptions runnig JasperRunManager.runReportToPdf(…)?

Sure this is my code:

[code]
JasperDesign jasperDesign = JRXmlLoader.load(resource.getInputStream());
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
jsonDS.setDatePattern(“yyyy-MM-dd HH:mm:ss”);
jsonDS.setNumberPattern(“#,##0.##”);
jsonDS.setLocale(Locale.US);

StreamResource.StreamSource source = new StreamResource.StreamSource() {
public InputStream getStream() {
byte b = null;
try{
b = JasperRunManager.runReportToPdf(jasperReport, preencherParametros(), jsonDS);

        } catch (Exception e) {
            Utils.showNotification(e.getMessage(), Type.ERROR_MESSAGE, UI.getCurrent().getPage());
        }
        return new ByteArrayInputStream(b);    
}   

};
StreamResource resourcesReport = new StreamResource(source, “Dashboard” + System.currentTimeMillis() + “.pdf”);
BrowserWindowOpener opener = new BrowserWindowOpener(resourcesReport);
opener.extend(downloadButton);

downloadButton.setVisible(true);
[/code]the error is in line

return new ByteArrayInputStream(b); So the generation of rel are perfect( any problem he will popup one message because of try… catch, but the problem are when I click in downloadButton ( to open a new window with the rel) It`s possible to vaadin lost the session from the byte? cause he create the byte
on memory and not local dir.

tks

I using springboot so I put the .jasper and .jrxml in the /resources/static/relatorios/

I using this code to get the file:

Resource resource =
resourceLoader.getResource(resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/DashboardCaixa.jrxml");

In my dev, works, I put in tomcat outside my eclipse and works too.

As far as I can see the only way you can get a NullPointerException on ByteArrayInputStream creation is that yout byte array
b
is null; and this can happen only if JasperRunManager.runReportToPdf(…) returns null or throws an Exception.

If you are sure that JasperRunManager.runReportToPdf(…) is not throwing exceptions yuo must investigate on runReportToPdf(…) execution itself.

By the way I’m not sure that you will see a vaadin notification if the generation throws exception because you are on a download request.

Regards
Marco

Marco I change my code to this:

StreamResource.StreamSource source = new StreamResource.StreamSource() {
    public InputStream getStream() {
            byte[] b = null;
            try{                                
                    b = JasperRunManager.runReportToPdf(jasperReport, preencherParametros(), jsonDS);               
            } catch (Exception e) {
                System.out.println("erro1");
                e.printStackTrace();
                Utils.showNotification(e.getMessage(), Type.ERROR_MESSAGE, UI.getCurrent().getPage());
            }
            return new ByteArrayInputStream(b);    
    }
};

And I dont got error when I try to generate the report, But I use this to load the jasper

Resources resource = resourceLoader.getResource(resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/DashboardCaixa.jrxml");

and I use

System.out.println(resourceLoader.CLASSPATH_URL_PREFIX); to see my classpath And the app print:

"classpath: "

But when I click in downloadButton (opener.extend(downloadButton):wink: in my View I got the error: resource not found at: classpath:/static/relatorio/DashboardCaixa.jasper

So, just to clarify, you have a spring boot project and you package it as a war archive;
.jasper and .jrxml files sources are located in src/main/resources/static/relatorios/ and inside the war they are in WEB-INF/classes/statics/realtorios.

Is this correct?

Correct.

Have you the full stack trace of the error?

Marco,

First I put this code to show my jrxml file pah

Resource resource = resourceLoader.getResource(resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/ChequesGeral.jrxml"); System.out.println(resource.getFile().getAbsolutePath()); And he print:

/var/lib/tomcat7/webapps/caixa/WEB-INF/classes/static/relatorios/ChequesGeral.jrxml

so the path are correct, but then he print :

net.sf.jasperreports.engine.JRException: Resource not found at: classpath:/static/relatorios/Cheques.jasper.
at net.sf.jasperreports.repo.RepositoryUtil.getResourceFromLocation(RepositoryUtil.java:153)
at net.sf.jasperreports.repo.RepositoryUtil.getReport(RepositoryUtil.java:112)
at net.sf.jasperreports.engine.fill.JRFillSubreport.loadReport(JRFillSubreport.java:398)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:365)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:427)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:341)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:121)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667)
at net.sf.jasperreports.engine.JasperRunManager.runToPdf(JasperRunManager.java:493)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(JasperRunManager.java:896)
at br.com.lumera.caixa.ui.DashboardCaixaView$5.getStream(DashboardCaixaView.java:827)
at com.vaadin.server.StreamResource.getStream(StreamResource.java:143)
at com.vaadin.server.AbstractClientConnector.handleConnectorRequest(AbstractClientConnector.java:673)
at com.vaadin.server.ConnectorResourceHandler.handleRequest(ConnectorResourceHandler.java:90)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:261)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:115)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at com.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:44)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2016-08-02 18:02:42.538 ERROR 8476 — [-8181-exec-1181]
com.vaadin.server.DefaultErrorHandler :

java.lang.NullPointerException: null
at java.io.ByteArrayInputStream.(ByteArrayInputStream.java:106) ~[na:1.8.0_101]

at br.com.lumera.caixa.ui.DashboardCaixaView$5.getStream(DashboardCaixaView.java:835) ~[DashboardCaixaView$5.class:na]

at com.vaadin.server.StreamResource.getStream(StreamResource.java:143) ~[vaadin-server-7.6.8.jar:7.6.8]

at com.vaadin.server.AbstractClientConnector.handleConnectorRequest(AbstractClientConnector.java:673) ~[vaadin-server-7.6.8.jar:7.6.8]

at com.vaadin.server.ConnectorResourceHandler.handleRequest(ConnectorResourceHandler.java:90) ~[vaadin-server-7.6.8.jar:7.6.8]

at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409) [vaadin-server-7.6.8.jar:7.6.8]

at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364) [vaadin-server-7.6.8.jar:7.6.8]

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) [servlet-api-3.0.jar:na]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:261) [spring-boot-actuator-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:115) [spring-boot-actuator-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103) [spring-boot-actuator-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]

at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [tomcat-catalina-7.0.52.jar:7.0.52]

at com.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:44) [tomcat70adaptor-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [tomcat-catalina-7.0.52.jar:7.0.52]

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) [tomcat-coyote-7.0.52.jar:7.0.52]

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) [tomcat-coyote-7.0.52.jar:7.0.52]

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315) [tomcat-coyote-7.0.52.jar:7.0.52]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]

at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

So I think the reporter are not found the .jasper file.

The Cheques.jasper are one sub-report, but I pass the dir of subreport with parameter:

parametros.put("SUBREPORT_DIR",resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/");

Are the same dir from ChequesGeral.jrxml and in reports I use $P{SUBREPORT_DIR}+"cheques.jasper

The Cheques.jasper are one sub-report, but I pass the dir of subreport with parameter:

parametros.put("SUBREPORT_DIR",resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/");

Are the same dir from ChequesGeral.jrxml and in reports I use $P{SUBREPORT_DIR}+“cheques.jasper”

Marco I solved.

The problem are when try to load the subreport:
this code dont work

parametros.put("SUBREPORT_DIR",resourceLoader.CLASSPATH_URL_PREFIX+"/static/relatorios/");

I change this to:

parametros.put("SUBREPORT_DIR",resource.getFile().getParent());
and works :smiley: tks for help

Hi Marco, thanks so much for posting this idea. I just implemented it in my project, and it does exactly what it was meant to do; however note that there is no default constructor in BrowserWindowOpener, so in order for the above example to work, my class has to invoke a constrcotr such as super(“”). This in turn invokes setResource, which causes opening of a window right after constructor invocation. I’ll appreciate any ideas how to work around it.

Thanks,
Reuben

Inovking super constructor with null should work.

super((Resource)null);

In this case on the connector side the url will be null and no window will be opened.

HTH
Marco

It works!
Thanks Marco.