Skip to main content



      Home
Home » Archived » BIRT » Embedded Images are not appearing in Web logic
Embedded Images are not appearing in Web logic [message #761928] Wed, 07 December 2011 04:50 Go to next message
Eclipse UserFriend
We have integrated BIRT in our application and sample code is as below. the images are embedded in reports. Now the problem is that images are appearing in tomcat but not in weblogic (attached screenshot).


// get report name and launch the engine
ByteArrayOutputStream out = new ByteArrayOutputStream();
String path=ApplicationBase.getInstance().getInitHash().getProperty("BIRT_WORKING_FOLDER");
String reportName = request.getParameter("ReportName");
ServletContext sc = request.getSession().getServletContext();
this.birtReportEngine = BirtEngine.getBirtEngine(sc);

// setup image directory
HTMLRenderContext renderContext = new HTMLRenderContext();
renderContext.setBaseImageURL(request.getContextPath() + "/images");
renderContext.setImageDirectory(sc.getRealPath("/images"));

HashMap<String, HTMLRenderContext> contextMap = new HashMap<String, HTMLRenderContext>();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);

IReportRunnable design;
try {
// Open report design
RequestParameterObject rpo = QueryCrypt.getInstance().decrypt(request);
String name = rpo.getParameter("ReportName");
reportName=name;
design = birtReportEngine.openReportDesign(path+"/birtreports" + "/" + reportName);
System.out.println("::::::path::::::"+path+"/birtreports" + "/" + reportName);
// create task to run and render report
IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);
task.setAppContext(contextMap);

// set output options
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
options.setEmbeddable(true);
options.setOutputStream(out);
task.setRenderOption(options);

ReportParameters rpm = new ReportParameters();
task = rpm.setReportParameters(rpo,task);

task.getAppContext().put("OdaJDBCDriverPassInConnection", DBaseBirt.getConnection());

// run report
task.run();
task.close();
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new ServletException(e);
}
return out;
Re: Embedded Images are not appearing in Web logic [message #762256 is a reply to message #761928] Wed, 07 December 2011 14:06 Go to previous messageGo to next message
Eclipse UserFriend
My guess is the sc.getRealPath is returning null when you are trying to
set the image directory.
Take a look at this post:

http://reach2ramesh.blogspot.com/2010/01/weblogic-servletcontextgetrealpath.html#!/2010/01/weblogic-servletcontextgetrealpath.html

Jason


On 12/7/2011 4:50 AM, shabz wrote:
> We have integrated BIRT in our application and sample code is as below. the images are embedded in reports. Now the problem is that images are appearing in tomcat but not in weblogic (attached screenshot).
>
>
> // get report name and launch the engine
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> String path=ApplicationBase.getInstance().getInitHash().getProperty("BIRT_WORKING_FOLDER");
> String reportName = request.getParameter("ReportName");
> ServletContext sc = request.getSession().getServletContext();
> this.birtReportEngine = BirtEngine.getBirtEngine(sc);
>
> // setup image directory
> HTMLRenderContext renderContext = new HTMLRenderContext();
> renderContext.setBaseImageURL(request.getContextPath() + "/images");
> renderContext.setImageDirectory(sc.getRealPath("/images"));
>
> HashMap<String, HTMLRenderContext> contextMap = new HashMap<String, HTMLRenderContext>();
> contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
>
> IReportRunnable design;
> try {
> // Open report design
> RequestParameterObject rpo = QueryCrypt.getInstance().decrypt(request);
> String name = rpo.getParameter("ReportName");
> reportName=name;
> design = birtReportEngine.openReportDesign(path+"/birtreports" + "/" + reportName);
> System.out.println("::::::path::::::"+path+"/birtreports" + "/" + reportName);
> // create task to run and render report
> IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);
> task.setAppContext(contextMap);
>
> // set output options
> HTMLRenderOption options = new HTMLRenderOption();
> options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
> options.setEmbeddable(true);
> options.setOutputStream(out);
> task.setRenderOption(options);
>
> ReportParameters rpm = new ReportParameters();
> task = rpm.setReportParameters(rpo,task);
>
> task.getAppContext().put("OdaJDBCDriverPassInConnection", DBaseBirt.getConnection());
>
> // run report
> task.run();
> task.close();
> } catch (Exception e) {
> logger.log(Level.SEVERE, e.getMessage(), e);
> throw new ServletException(e);
> }
> return out;
>
Re: Embedded Images are not appearing in Web logic [message #915936 is a reply to message #762256] Tue, 18 September 2012 04:46 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jason,

It is appearing in the PDF and Excel but not in HTML.
Re: Embedded Images are not appearing in Web logic [message #915954 is a reply to message #915936] Tue, 18 September 2012 05:36 Go to previous messageGo to next message
Eclipse UserFriend
I got it working by changing the weblogic.xml

<container-descriptor>
<show-archived-real-path-enabled>true
</show-archived-real-path-enabled>
</container-descriptor>

Thanks Jason.
Re: Embedded Images are not appearing in Web logic [message #916154 is a reply to message #915954] Tue, 18 September 2012 12:12 Go to previous message
Eclipse UserFriend
Thanks for posting your solution.

Jason
Previous Topic:Crosstab issue - not to sort alphabetically
Next Topic:Dynamically read resource bundle files
Goto Forum:
  


Current Time: Sat May 17 06:40:22 EDT 2025

Powered by FUDForum. Page generated in 0.03719 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top