我完成了一个包含jasperreport的项目。它可以毫无问题地在服务器中获取excel文件。但是,当软件在服务器中运行时,如果调用了jasper报告代码,则会显示错误。
我使用jasper report的fillReport方法导出xls。我的代码如下:如何解决该问题
Connection conn = getConnection();
String jasperResource = "/reports/" + report.getName() + ".jasper";
InputStream jasperStream = getClass().getResourceAsStream(jasperResource);
//InputStreamReader inputStreamReader = new InputStreamReader(jasperStream, Charset.forName("UTF-8"));
//JasperReport jasperReport = JasperCompileManager.compileReport(jasperStream);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(jasperStream);
JRDesignStyle jrDesignStyle = new JRDesignStyle();
//jrDesignStyle.setPdfEncoding("UTF-8");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, param, conn);
在服务器端,我收到此错误:
没有输入源提供给出口商
'net.sf.jasperreports.engine.JRRuntimeException: No input source supplied to the exporter.
at net.sf.jasperreports.export.parameters.ParametersExporterInput.getJas perPrintList(ParametersExporterInput.java:101)
at net.sf.jasperreports.export.parameters.ParametersExporterInput.<init> (ParametersExporterInput.java:54)
at net.sf.jasperreports.engine.JRAbstractExporter.ensureInput(JRAbstract Exporter.java:724)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.ensureInput( JRXlsAbstractExporter.java:1021)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport (JRXlsAbstractExporter.java:994)
at com.sbb.puantajhesaplama.service.impl.JasperServiceImpl.exportReportF ile(JasperServiceImpl.java:126)
at com.sbb.puantajhesaplama.service.impl.JasperServiceImpl.downloadRepor tFile(JasperServiceImpl.java:143)
at com.sbb.puantajhesaplama.service.impl.JasperServiceImpl$$FastClassByS pringCGLIB$$a72fc882.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:2 04)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation .invokeJoinpoint(CglibAopProxy.java:746)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed( ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport. invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.in voke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed( ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterce ptor.intercept(CglibAopProxy.java:688)
at com.sbb.puantajhesaplama.service.impl.JasperServiceImpl$$EnhancerBySp ringCGLIB$$1204e07c.downloadReportFile(<generated>)
at com.sbb.puantajhesaplama.web.rest.PersonelKatilimResource.getFile(Per sonelKatilimResource.java:174)
at com.sbb.puantajhesaplama.web.rest.PersonelKatilimResource$$FastClassB ySpringCGLIB$$25b1bfa.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:2 04)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterce ptor.intercept(CglibAopProxy.java:684)
at com.sbb.puantajhesaplama.web.rest.PersonelKatilimResource$$EnhancerBy SpringCGLIB$$a97951e4.getFile(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvok e(InvocableHandlerMethod.java:209)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeF orRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocabl eHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingH andlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:891)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingH andlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapt er.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch erServlet.java:991)
at org.springframework.web.servlet.DispatcherServlet.doService(Dispatche rServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(Frame workServlet.java:974)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServ let.java:877)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkSer vlet.java:851)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHand ler.java:74)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:129)
at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(Abst ractInstrumentedFilter.java:111)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:101)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.do FilterInternal(HttpTraceFilter.java:90)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:320)
at org.springframework.security.web.access.intercept.FilterSecurityInter ceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInter ceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.access.ExceptionTranslationFilter.do Filter(ExceptionTranslationFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.session.SessionManagementFilter.doFi lter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AnonymousAuthenticati onFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.rememberme.RememberMe AuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:158)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.servletapi.SecurityContextHolderAwar eRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter .doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AbstractAuthenticatio nProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.logout.LogoutFilter.d oFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(Csr fFilter.java:124)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter .java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterIn ternal(HeaderWriterFilter.java:66)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFi lter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManage rIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(Fi lterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChai nProxy.java:178)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(D elegatingFilterProxy.java:357)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(Delegat ingFilterProxy.java:270)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal( RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInter nal(HttpPutFormContentFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInterna l(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFil ter.filterAndRecordMetrics(WebMvcMetricsFilter.java:155)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFil ter.filterAndRecordMetrics(WebMvcMetricsFilter.java:123)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFil ter.doFilterInternal(WebMvcMetricsFilter.java:108)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterIntern al(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerR equestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61 )
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(F ilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandle r.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.hand leRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChai n.java:65)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest( ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandle r.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandle r.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH andler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRe quest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstrain tHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleR equest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandl er.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandl er.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH andler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateH andler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest (ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(Servlet InitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInit ialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInit ialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.cal l(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(Context ClassLoaderSetupAction.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(Se rvletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(Servlet InitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(Se rvletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:336)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:8 30)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor. java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:624)
at java.lang.Thread.run(Thread.java:748)
2019-04-02 13:21:23.628 WARN 506 --- [ XNIO-2 task-15] .m.m.a.ExceptionHandlerE xceptionResolver : Resolved [net.sf.jasperreports.engine.JRRuntimeException: No input source supplied to the exporter.]
'
前端显示类似500 (Internal Server Error)