当前位置: 首页 > 知识库问答 >
问题:

调用BirtReport时,查看会话不可用或已过期

南宫阳冰
2023-03-14

我尝试从控制器调用Birt报告,如下所示:

@RequestMapping(value = "/birtReport", method = RequestMethod.GET)
@ApiOperation("Download Report")
public void birtReport(HttpServletRequest request,HttpServletResponse response) throws ErrorExceptions, IOException{
        HttpClient httpClient = HttpClients.createDefault();
        HttpPost postRequest = new HttpPost("http://localhost:8080/birt/run?__report=MyFirstReport.rptdesign&id=211");
        HttpResponse response1 = httpClient.execute(postRequest);
        InputStream body = response1.getEntity().getContent();
        IOUtils.copy(body, response.getOutputStream());
        response.flushBuffer();

    }

我真正做的是调用一个控制器,该控制器调用另一个Tomcat服务器上存在的birt报告,但我收到以下错误:

堆栈跟踪:

java.lang.IllegalStateException: The viewing session is not available or has expired.
   at org.eclipse.birt.report.service.ReportEngineService.createRunAndRenderTask(ReportEngineService.java:1042)
   at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:911)
   at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
   at org.eclipse.birt.report.service.actionhandler.BirtGetPageAllActionHandler.__execute(BirtGetPageAllActionHandler.java:131)
   at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
   at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47)
   at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143)
   at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleGetPageAll(BirtDocumentProcessor.java:183)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112)
   at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66)
   at sun.reflect.GeneratedMethodAccessor577.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:265)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
   at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:122)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
   at org.eclipse.birt.report.filter.ViewerFilter.doFilter(ViewerFilter.java:68)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
   at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
   at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:500)
   at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
   at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
   at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
   at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   at java.lang.Thread.run(Thread.java:745)

这是从API调用Bert报告的最佳方式吗?

共有1个答案

张晔
2023-03-14

我能够通过使用报告引擎解决我的问题,这就是控制器代码:

@RequestMapping(value = "/birtReport1", method = RequestMethod.GET)
@ApiOperation("Download Report")
public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        //get report name and launch the engine
        resp.setContentType("text/html");
//      resp.setContentType( "application/pdf" ); 
        //resp.setHeader ("Content-Disposition","inline; filename=test.pdf");       
        String reportName = "/Documents/workspace/Birt/MyFirstReport.rptdesign";
        ServletContext sc = req.getSession().getServletContext();
        this.birtReportEngine = BirtEngine.getBirtEngine(sc);
        IReportRunnable design;
        try
        {
            //Open report design
            design = birtReportEngine.openReportDesign( reportName );
            //create task to run and render report
            IRunAndRenderTask task = 
            birtReportEngine.createRunAndRenderTask( design );      
            String[] values = {"10096", "10094"};
            task.setParameterValue("idCatalogue",values);
            HTMLRenderOption options = new HTMLRenderOption();
        options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
            options.setOutputStream(resp.getOutputStream());
            task.setRenderOption(options);

            //run report
            task.run();
            task.close();
        }catch (Exception e){

            e.printStackTrace();
            throw new ServletException( e );
        }
    }
 类似资料:
  • 问题内容: 我的webapp有登录的用户。有超时。在会话到期之前,我想执行一种方法来清除一些锁。 我已经实现了一个,但是一旦到达会话,会话就已经消失了,我需要从中获取一些数据,因此我想在会话实际过期之前执行一个方法(该会话需要运行并可以访问)。 我怎样才能做到这一点?有任何想法吗?这是我的会话监听器: 但我要去的原因是null或返回null 问题答案: 您可以通过实现HttpSessionBind

  • 问题内容: 我有一个会话验证过滤器,当会话过期时该过滤器注销用户。 这是一段代码,但是没有用。不起作用意味着即使会话过期,它也不会重定向到登录页面。 请帮助我解决此问题。 问题答案: 我有一个会话验证过滤器,当会话过期时该过滤器注销用户。 老实说,这完全没有道理。如果将已登录用户存储为会话的属性,并基于会话中已登录用户的存在来拦截“已登录”状态,则在任何时候都不需要手动注销该用户。会话已过期。当会

  • 在我的ATG应用程序中,当我使用checkFormRedirect将用户重定向到带有一些参数的jsp页面时,我得到的参数为NULL。请参阅下面的FormHandler代码: UserFormHandler: test.jsp: 此外,我尝试在formHandler中使用变量并设置值,但仍然得到的值为NULL。能不能帮点忙。

  • 我在Tomcat7中有一个web应用程序,它将会话中的用户信息作为DTO对象保存。我还为我的项目启用了Spring Security性,如果用户没有会话,它会自动将用户重定向到登录页面。 如果我登录到应用程序一次,然后在Eclipse中重新启动Tomcat,会发生的情况是,我的会话被冲出,但cookie没有运行。 Edit:尽管Firefox说,但如果关闭并重新启动Firefox,cookie仍然

  • 我正在开发一个vaadin web应用程序,我在web.xml中添加了以下代码片段。 现在我注意到,也在30分钟后,我的用户能够使用应用程序,我不想这样。我在vaadin的书上读到了一些关于这个问题的东西,但我并不了解一些东西。 在web.xml中: 会话超时应长于心跳间隔,否则会话在心跳保持活动之前就已关闭。由于会话过期使UI处于假定会话仍然存在的状态,这将在浏览器中导致不同步错误通知。 但是,

  • 我正在尝试运行电子商务演示应用程序的自动化脚本。但在将项目添加到购物车时,项目将添加到购物车,但登录会话已过期。我使用selenium、testNG工具和java编程语言开发了脚本。