problem running a report with pie chart in web

Rain
edited February 11, 2022 in Analytics #1
hi, i've been trying to create a report with a pie chart and a table..i was able to create the report in an html format, but the problem is...it was blank., the details are not seen..also the pie chart..i don't know what's the problem..

can anyone please help me?

my code goes like this..

public void selectReport() {

EngineConfig config = new EngineConfig();
// Setting the Report Engine Home..this is where the ReportEngine folder is located.
config.setEngineHome("/home/charina/birtruntime/birt-runtime-2_2_2/ReportEngine");

// Create the engine.
ReportEngine engine = new ReportEngine(config);

// Accessing a report engine design
String designName = "workspace/pbi-dms/WebContent/reports/per_originator_dept.rptdesign";
IReportRunnable runnable = null;

try {
runnable = engine.openReportDesign(designName);
} catch (EngineException e) {
System.err.println("Design " + designName + " not found!");
engine.shutdown();
System.exit(-1);
}

// Create a run and render task object.
IRunAndRenderTask task = engine.createRunAndRenderTask(runnable);

// Set the name of an output file.
HTMLRenderOption options = new HTMLRenderOption();
String output = designName.replaceFirst(".rptdesign", ".html");
// Set a location where to Save the report.
options.setOutputFileName("/home/charina/Documents/per_originator_dept.html");
options.setOutputFormat("html");

// Apply the rendering options to the task.
task.setRenderOption(options);

// Set up writing images or charts embedded in HTML output.
HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler( );
HTMLEmitterConfig hc = new HTMLEmitterConfig( );
hc.setImageHandler( imageHandler );
config.setEmitterConfiguration( RenderOptionBase.OUTPUT_FORMAT_HTML, hc );


// Apply the rendering context to the task.
HashMap appContext = new HashMap();
HTMLRenderContext renderContext = new HTMLRenderContext();
appContext.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
task.setAppContext(appContext);

// Set Parameter Values
task.setParameterValue("paramDepartment", paramDepartment);
// Set the Date parameter

// date.getTime();
// task.setParameterValue("paramFrom", paramFrom);
// task.setParameterValue("paramTo", paramTo);

// task.setParameterValue("paramReports", (new String("DCN STATUS PER ORIGINATOR DEPARTMENT")));

HashMap parameterValues = task.getParameterValues();
// Set values for all parameters in a HashMap, parameterValues
task.setParameterValues(parameterValues);
// Validate parameter values.
boolean parametersAreGood = task.validateParameters();

// Generating a report from a report design

try {
task.run();
System.out.println("Created Report " + options + ".");
} catch (EngineException e1) {
System.err.println("Report " + designName + " run failed.");
System.err.println(e1.toString());
}
engine.shutdown();

}


thank's...

rain

Comments

  • cypherdj
    edited December 31, 1969 #2
    Hi Rain,<br />
    <br />
    to produce your images, you need the renderoption to specify the supported output format(s), base image url and image directory<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    IRenderOption option = new HTMLRenderOption();

    option.setBaseImageURL("<yourAppContext>/report/images");
    option.setImageDirectory("<RealPath>/report/images");
    option.setImageHandler(new HTMLServerImageHandler());
    option.setSupportedImageFormats("SVG");
    </pre>
    <br />
    I only use setOutputFilename in a run then render tasks scenario, and use setOutputStream with a runAndRender task, I might be wrong. How do you display the report in your web browser? JSP page?<br />
    <br />
    Let me know if you're still having problems,<br />
    Cedric
  • Rain
    edited December 31, 1969 #3
    Hi Cedric,

    I've tried to use the code but im still having a problem..still the report is there..but blank.. :-(
    this is the error:

    java: xcb_xlib.c:50: xcb_xlib_unlock: Assertion `c->xlib.lock' failed.

    Im using jsp page in running the report.,it's working when there's no chart included in my table.. i think i need to use an httpServlet but im afraid, i cant understand how to use it right now. Is there any way i might run the report in a simple way?ahmm..atleast for the meantime..so i can see the result of my report in a web..

    i would really appreciate your help..thank's..

    Rain
  • cypherdj
    edited December 31, 1969 #4
    Hi Rain,<br />
    <br />
    you could just use the BirtViewer to view your report, or you could implement your own servlet.<br />
    <br />
    This article by Jason should guide you through it:<br />
    <a class='bbc_url' href='http://www.onjava.com/pub/a/onjava/2006/07/26/deploying-birt.html?page=1'>http://www.onjava.com/pub/a/onjava/2006/07/26/deploying-birt.html?page=1</a><br />
    <br />
    Hope that helps,<br />
    Cedric
  • Rain
    edited December 31, 1969 #5
    Hi,

    I've been trying to build the servlet..and I was able to view the "POST" method., but my new problem is that when i try to use the "GET" method., there was an error that goes like this:

    org.eclipse.birt.core.exception.BirtException: Cant startup the OSGI framework
    at org.eclipse.birt.core.framework.Platform.startup(Platform.java:90)
    at com.pbi.qa.qs.dcn.backingbean.BirtEngine.getBirtEngine(BirtEngine.java:62)
    at com.pbi.qa.qs.dcn.backingbean.WebReport.doGet(WebReport.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: org.eclipse.birt.core.exception.BirtException: Could not find the Framework - org.eclipse.osgi
    at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:95)
    at org.eclipse.birt.core.framework.Platform.startup(Platform.java:78)
    ... 16 more
    Jul 3, 2008 2:12:48 PM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet WebReport threw exception
    java.lang.NullPointerException
    at com.pbi.qa.qs.dcn.backingbean.BirtEngine.getBirtEngine(BirtEngine.java:69)
    at com.pbi.qa.qs.dcn.backingbean.WebReport.doGet(WebReport.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)


    i think there is a problem with these lines:
    this.birtReportEngine = BirtEngine.getBirtEngine(sc);
    -- the birtReportEngine is "null" when i Run it on a debug mode
    String reportName = req.getParameter("reportName");
    -- the reportName is also "null"..

    i am thinking if i could put the reportName which is "per_originator_dept.rptdesign" at the BirtConfig.properties..but it still doesn't work..also the engineHome..my reportEngine folder together with its configs and plugins.,library..etc..are in a different folder..so, i think i also need to declare the engine home at the BirtConfig.properties?

    Thank's for all the suggestions..it really helps me a lot...
  • cypherdj
    edited December 31, 1969 #6
  • Rain
    edited December 31, 1969 #7
    Hi Cedric,

    Thank's for the help..i finally figured out the problem..the birtEngine couldn't find the birtEngine home..i put the platform folder under the WEB-INF folder, following what the error says..

    -/home/charina/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/pbi-dms/WEB-INF/platform

    Thank's again..

    Rain
  • Rain
    edited December 31, 1969 #8
    hi again,

    now, i've got another problem..m sure it's the image(pie chart)..when i created a servlet, i decided to first removed the image..that's why now i have a servlet, and its working fine..now that i put the image again on my report..it gives me the same error again..

    java: xcb_xlib.c:50: xcb_xlib_unlock: Assertion `c->xlib.lock' failed.

    here's my code for the imageHandler:

    // set output options
    HTMLRenderOption options = new HTMLRenderOption();
    // set the image handler to a HTMLServerImageHandler if you plan on using the base image url.
    options.setImageHandler(new HTMLServerImageHandler());
    options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
    // options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
    options.setOutputStream(resp.getOutputStream());
    options.setBaseImageURL(req.getContextPath() + "/WebContent/reports");
    options.setImageDirectory(sc.getRealPath("/WebContent/reports"));
    task.setRenderOption(options);
  • cypherdj
    edited December 31, 1969 #9
    Hi Rain,<br />
    <br />
    I have never come across this problem, but I believe this is a linux issue, and I'm working on Windows platform. Are you using OpenSuse by any chance?<br />
    <br />
    If so, have a look at this article:<br />
    <a class='bbc_url' href='http://en.opensuse.org/Xlib.lock'>http://en.opensuse.org/Xlib.lock</a><br />
    <br />
    here's a possible workaround:<br />
    <a class='bbc_url' href='http://scorreiait.wordpress.com/2007/11/21/graphical-java-programs-assertion-c-xliblock-failed/'>http://scorreiait.wordpress.com/2007/11/21/graphical-java-programs-assertion-c-xliblock-failed/</a><br />
    <br />
    Hope that helps,<br />
    Cedric