Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:50 Go to next message
shabz Missing name is currently offline shabz Missing nameFriend
Messages: 15
Registered: October 2011
Junior Member
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 19:06 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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 08:46 Go to previous messageGo to next message
shabz Missing name is currently offline shabz Missing nameFriend
Messages: 15
Registered: October 2011
Junior Member
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 09:36 Go to previous messageGo to next message
shabz Missing name is currently offline shabz Missing nameFriend
Messages: 15
Registered: October 2011
Junior Member
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 16:12 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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: Fri Apr 26 07:58:41 GMT 2024

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

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

Back to the top