Python中文网

一个关于 编程问题的解答网站.

有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JSF2是由java引起的。伊奥。使用Jasperreports时发生FileNotFoundException错误

很多人都在研究jasperreports,我被错误锁定了。真的不知道在哪里我可能会错过,因为这是第一次使用

出现错误:java.io.FileNotFoundException:

    17:34:08,009 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: C:\jboss-as-7.1.1.Final\standalone\deployments\fittaxi.war\src\main\webapp\relatorios\voucher.jasper

17:34:08,012 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:114)

17:34:08,013 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:103)

17:34:08,014 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:580)

17:34:08,015 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:930)

17:34:08,017 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at br.com.eptc.taxi.tarifa.util.UtilRelatorios.imprimeRelatorio(UtilRelatorios.java:29)

17:34:08,018 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at br.com.eptc.taxi.tarifa.view.VoucherBean.imprimirVoucher(VoucherBean.java:439)

17:34:08,019 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

17:34:08,020 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

17:34:08,021 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

17:34:08,022 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at java.lang.reflect.Method.invoke(Unknown Source)

17:34:08,023 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

17:34:08,025 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,026 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)

17:34:08,027 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)

17:34:08,029 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)

17:34:08,030 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

17:34:08,031 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,033 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

17:34:08,034 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

17:34:08,035 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,036 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

17:34:08,038 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,039 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58)

17:34:08,040 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,041 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:156)

17:34:08,043 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,044 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82)

17:34:08,046 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,047 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

17:34:08,048 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,049 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

17:34:08,050 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

17:34:08,052 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,053 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:66)

17:34:08,055 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,056 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)

17:34:08,057 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)

17:34:08,058 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

17:34:08,059 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,060 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

17:34:08,062 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,063 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

17:34:08,064 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,066 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

17:34:08,067 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,068 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)

17:34:08,069 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,071 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

17:34:08,072 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,073 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

17:34:08,074 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

17:34:08,075 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)

17:34:08,077 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,078 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52)

17:34:08,079 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

17:34:08,080 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

17:34:08,082 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

17:34:08,083 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at br.com.eptc.taxi.tarifa.view.VoucherBean$$$view252.imprimirVoucher(Unknown Source)

17:34:08,084 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

17:34:08,085 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

17:34:08,086 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

17:34:08,087 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at java.lang.reflect.Method.invoke(Unknown Source)

17:34:08,088 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)

17:34:08,090 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)

17:34:08,091 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)

17:34:08,092 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)

17:34:08,093 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:111)

17:34:08,095 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)

17:34:08,096 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

17:34:08,097 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at br.com.eptc.taxi.tarifa.view.VoucherBean$Proxy$_$$_Weld$Proxy$.imprimirVoucher(VoucherBean$Proxy$_$$_Weld$Proxy$.java)

17:34:08,099 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at br.com.eptc.taxi.tarifa.view.VoucherBean$Proxy$_$$_WeldClientProxy.imprimirVoucher(VoucherBean$Proxy$_$$_WeldClientProxy.java)

17:34:08,100 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

17:34:08,101 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

17:34:08,102 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

17:34:08,103 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at java.lang.reflect.Method.invoke(Unknown Source)

17:34:08,104 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.el.parser.AstValue.invoke(AstValue.java:262)

17:34:08,105 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

17:34:08,107 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)

17:34:08,108 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)

17:34:08,109 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

17:34:08,110 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)

17:34:08,112 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

17:34:08,113 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at javax.faces.component.UICommand.broadcast(UICommand.java:315)

17:34:08,114 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

17:34:08,115 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

17:34:08,116 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

17:34:08,117 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

17:34:08,118 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

17:34:08,119 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

17:34:08,120 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

17:34:08,122 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

17:34:08,123 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

17:34:08,124 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

17:34:08,126 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

17:34:08,127 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

17:34:08,129 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

17:34:08,130 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

17:34:08,131 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

17:34:08,133 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

17:34:08,134 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

17:34:08,135 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

17:34:08,136 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

17:34:08,137 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

17:34:08,139 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

17:34:08,140 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

17:34:08,141 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at java.lang.Thread.run(Unknown Source)

17:34:08,142 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) Caused by: java.io.FileNotFoundException: C:\jboss-as-7.1.1.Final\standalone\deployments\fittaxi.war\src\main\webapp\relatorios\voucher.jasper

17:34:08,144 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   ... 106 more

我的班级:

    public class UtilRelatorios {
        public static void imprimeRelatorio(String relatorioNome,
            HashMap parametros) {
        try{
            JRBeanCollectionDataSource dataSource =
                    new JRBeanCollectionDataSource(null);
            FacesContext facesContext = FacesContext.getCurrentInstance();
            ServletContext scontext = 
                    (ServletContext) facesContext.getExternalContext().getContext();
            String path = scontext.getRealPath("src/main/webapp/relatorios");
            JasperPrint jasperPrint = 
                    JasperFillManager.fillReport(
                            scontext.getRealPath("src/main/webapp/relatorios")+ File.separator+relatorioNome+".jasper",
                            parametros, dataSource);
            byte[] b = JasperExportManager.exportReportToPdf(jasperPrint);
            HttpServletResponse res = (HttpServletResponse)
                    facesContext.getExternalContext().getResponse();
            res.setContentType("application/pdf");
            int codigo = (int) (Math.random()*1000);
            res.setHeader("Content-disposition","inline);filename=relatorio_"+codigo+".pdf");
            res.getOutputStream().write(b);
            facesContext.renderResponse();
        }catch (Exception e){
            e.printStackTrace();
        }       
    }   
}

我的方法是:

public void imprimirVoucher(){
    HashMap parametros = new HashMap();
    parametros.put("dataEmissao", voucher.getDataEmissao());
    parametros.put("hora", voucher.getHora());
    parametros.put("bandeiraNome", voucher.getBandeiraIntervalo().getBandeira().getNome());
    parametros.put("prefixo", voucher.getVeiculo().getPrefixo());
    parametros.put("volPequenos", voucher.getVolumePequeno() );
    parametros.put("volNormais", voucher.getVolumeNormal() );
    parametros.put("volgrandes", voucher.getVolumeGrande());
    parametros.put("totalVolPequenos", voucher.getTotalVolumesPequenos());
    parametros.put("totalVolNormais", voucher.getTotalVolumesNormais());
    parametros.put("totalVolGrandes", voucher.getTotalVolumesGrandes());
    parametros.put("valorCorrida",voucher.getValorCorrida());
    parametros.put("valorVoucher",voucher.getValorVoucher());
    parametros.put("origem", voucher.getOrigem().getNomeFantasia());
    parametros.put("destino",voucher.getDestinoVoucher() );
    parametros.put("passageiro", voucher.getPessoa().getNome());
    parametros.put("observacao", voucher.getObservacao());
    parametros.put("id",voucher.getId() );
    parametros.put("formaPagamento", voucher.getFormaPagamento().getNome() );           
    UtilRelatorios.imprimeRelatorio("voucher", parametros);
}

我的comandLink

<h:commandLink action="#{voucherBean.imprimirVoucher()}" value="Imprimir" 
                styleClass="btn btn-primary"  target="_blank" />

共 (1) 个答案

  1. # 1 楼答案

    行动电话

    String path = scontext.getRealPath("src/main/webapp/relatorios");
    JasperPrint jasperPrint = JasperFillManager.fillReport(scontext.getRealPath("src/main/webapp/relatorios")+ File.separator+relatorioNome+".jasper", parametros, dataSource);
    

    也就是说,他引用了src/main/webapp/relatorios中的文件。这可能适用于有源文件树的开发机器上的测试类,但Maven通常不会将src文件夹放入最终部署的WAR中

    然而,在本案中,所讨论的文件来自^{。此文件夹的内容将复制到WAR根目录中。因此

    String path = scontext.getRealPath("relatorios");
    JasperPrint jasperPrint = JasperFillManager.fillReport(scontext.getRealPath("relatorios")+ File.separator+relatorioNome+".jasper", parametros, dataSource);
    

    应该有用。尽管如此

    • 我不确定JBoss是否真的提取了战争。如果没有,就没有真正的道路。但是,查看文档,可以看到getRealPath返回null,如果servlet容器无法将给定的虚拟路径转换为真实路径由于问题与null值无关,因此JBoss似乎在提取
    • 我怀疑你是否想公开你的*.jasper文件。但在你的情况下,他们似乎是