Home
Analytics
Deploying report designs in a separate web project from the viewer
javaguy
I don't know if this has been asked or not, so here goes.
I have a java project that I am currently running BIRT reports in using the viewer. I have customized my viewer, so it is residing in my workspace as a project. Currently, my report designs are living in the viewer project, and so every time I change or add a report design, I have to redeploy the entire viewer project, which takes a really long time.
Is there a way to put the report designs in their own web project so I can deploy them separately and still have the viewer able to find them?
Find more posts tagged with
Comments
JasonW
When you use the viewer __report parameter you can specify the complete path to any report. ie __report=c:/temp/myreports/report.rptdesign.
So you should be able to do what you want.
Jason
javaguy
I'm not going to have my report designs just sitting anywhere by themselves on the server. I have them in a java web project and I deploy that project to the server. I need to be able to reference the relative URL specified in the deployment plan.
An absolute path won't help me.
JasonW
Can you specify a full URL ie <a class='bbc_url' href='
http://localhost:8080/reports/MyReport.rptdesign?'>http://localhost:8080/reports/MyReport.rptdesign?</a><br
/>
<br />
Jason
javaguy
I could, but then it would only work on my local machine. I wouldn't be able to test it in our test environment and it wouldn't work in production.
JasonW
It does not have to be local host. It could be any url that has the report.
javaguy
Yes, but what I mean is that I would have to change it for every environment I wanted to run it in. Isn't there a way to avoid having to do that?
JasonW
The only way I know to do this is to modify the viewer code to lookup a context in the appserver to locate your reports.
Jason
javaguy
OK, I added the localhost URL for my report design location to the viewer's _report parameter, but as I traced through my code, the URL mysteriously reverted back to the way it was before, without the path to the report project. Something changed it back to think that the report designs should be residing in the viewer project. I have set the WORKING_FOLDER_ACCESS_ONLY parameter to false, so why would it be doing this?
I did notice one strange thing. If I have a report design in the viewer project AND the url of the external report, then the URL is kept the way I want it - going to the external report design.
Any ideas?
JasonW
If this:
WORKING_FOLDER_ACCESS_ONLY
is false it should be working. Are you deploying the viewer as a normal web app?
Jason
javaguy
yes, the viewer project is a web app
javaguy
OK, here's some code. First, my viewer project's web.xml:
<?xml version="1.0" encoding="utf-8"?>
<web-app
xmlns="
http://java.sun.com/xml/ns/j2ee"
;
version="2.4"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
;
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
;
<display-name>Eclipse BIRT Report Viewer</display-name>
<!-- Default locale setting.
-->
<context-param>
<param-name>BIRT_VIEWER_LOCALE</param-name>
<param-value>en-US</param-value>
</context-param>
<!--
Default timezone setting.
Examples: "Europe/Paris", "GMT+1".
Defaults to the container's timezone.
-->
<context-param>
<param-name>BIRT_VIEWER_TIMEZONE</param-name>
<param-value></param-value>
</context-param>
<!--
Report resources directory for preview. Defaults to ${birt home}
-->
<context-param>
<param-name>BIRT_VIEWER_WORKING_FOLDER</param-name>
<param-value>
http://localhost:8080/Reports/</param-value>
;
</context-param>
<!--
Temporary document files directory. Defaults to ${birt home}/documents
-->
<context-param>
<param-name>BIRT_VIEWER_DOCUMENT_FOLDER</param-name>
<param-value></param-value>
</context-param>
<!--
Flag whether the report resources can only be accessed under the
working folder. Defaults to true
-->
<context-param>
<param-name>WORKING_FOLDER_ACCESS_ONLY</param-name>
<param-value>false</param-value>
</context-param>
<!--
Temporary image/chart directory. Defaults to ${birt home}/report/images
-->
<context-param>
<param-name>BIRT_VIEWER_IMAGE_DIR</param-name>
<param-value></param-value>
</context-param>
<!-- Engine log directory. Defaults to ${birt home}/logs -->
<context-param>
<param-name>BIRT_VIEWER_LOG_DIR</param-name>
<param-value></param-value>
</context-param>
<!-- Report engine log level -->
<context-param>
<param-name>BIRT_VIEWER_LOG_LEVEL</param-name>
<param-value>WARNING</param-value>
</context-param>
<!--
Directory where to store all the birt report script libraries (JARs).
Defaults to ${birt home}/scriptlib
-->
<context-param>
<param-name>BIRT_VIEWER_SCRIPTLIB_DIR</param-name>
<param-value></param-value>
</context-param>
<!-- Resource location directory. Defaults to ${birt home} -->
<context-param>
<param-name>BIRT_RESOURCE_PATH</param-name>
<param-value></param-value>
</context-param>
<!-- Preview report rows limit. An empty value means no limit. -->
<context-param>
<param-name>BIRT_VIEWER_MAX_ROWS</param-name>
<param-value></param-value>
</context-param>
<!--
Max cube fetch levels limit for report preview (Only used when
previewing a report design file using the preview pattern)
-->
<context-param>
<param-name>BIRT_VIEWER_MAX_CUBE_ROWLEVELS</param-name>
<param-value></param-value>
</context-param>
<context-param>
<param-name>BIRT_VIEWER_MAX_CUBE_COLUMNLEVELS</param-name>
<param-value></param-value>
</context-param>
<!-- Memory size in MB for creating a cube. -->
<context-param>
<param-name>BIRT_VIEWER_CUBE_MEMORY_SIZE</param-name>
<param-value></param-value>
</context-param>
<!-- Defines the BIRT viewer configuration file -->
<context-param>
<param-name>BIRT_VIEWER_CONFIG_FILE</param-name>
<param-value>WEB-INF/viewer.properties</param-value>
</context-param>
<!--
Flag whether to allow server-side printing. Possible values are "ON"
and "OFF". Defaults to "ON".
-->
<context-param>
<param-name>BIRT_VIEWER_PRINT_SERVERSIDE</param-name>
<param-value>ON</param-value>
</context-param>
<!--
Flag whether to force browser-optimized HTML output. Defaults to true
-->
<context-param>
<param-name>HTML_ENABLE_AGENTSTYLE_ENGINE</param-name>
<param-value>true</param-value>
</context-param>
<!--
Filename generator class/factory to use for the exported reports.
-->
<context-param>
<param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name>
<param-value>org.eclipse.birt.report.utility.filename.DefaultFilenameGenerator</param-value>
</context-param>
<!--
Viewer Filter used to set the request character encoding to UTF-8.
-->
<filter>
<filter-name>ViewerFilter</filter-name>
<filter-class>org.eclipse.birt.report.filter.ViewerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ViewerFilter</filter-name>
<servlet-name>ViewerServlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>ViewerFilter</filter-name>
<servlet-name>EngineServlet</servlet-name>
</filter-mapping>
<!-- Viewer Servlet Context Listener -->
<listener>
<listener-class>org.eclipse.birt.report.listener.ViewerServletContextListener</listener-class>
</listener>
<!-- Viewer HttpSession Listener -->
<listener>
<listener-class>org.eclipse.birt.report.listener.ViewerHttpSessionListener</listener-class>
</listener>
<!-- Viewer Servlet, Supports SOAP -->
<servlet>
<servlet-name>ViewerServlet</servlet-name>
<servlet-class>org.eclipse.birt.report.servlet.ViewerServlet</servlet-class>
</servlet>
<!-- Engine Servlet -->
<servlet>
<servlet-name>EngineServlet</servlet-name>
<servlet-class>org.eclipse.birt.report.servlet.BirtEngineServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ViewerServlet</servlet-name>
<url-pattern>/frameset</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ViewerServlet</servlet-name>
<url-pattern>/run</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/preview</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/download</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/parameter</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/document</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/output</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>EngineServlet</servlet-name>
<url-pattern>/extract</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>/birt.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/birt.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
Next, my java method that builds the URL:
public void generateCanteenSalesReport(){
String report="";
String bdate = DateUtils.getYYYY_MM_DD(this.startDate);
String edate = DateUtils.getYYYY_MM_DD(this.endDate);
if(this.getReportType().equals("S")){
report="/POSReports/frameset?__report=CanteenSalesSummary.rptdesign&pin="
+ this.selectedInstitutionId + "&canteen=" + this.selectedCanteenId + "&bDate=" + bdate + "&eDate=" + edate;
} else {
report="/POSReports/frameset?__report=CanteenSalesDetail.rptdesign&pin="
+ this.selectedInstitutionId + "&canteen=" + this.selectedCanteenId + "&bDate=" + bdate + "&eDate=" + edate;
}
String url = FacesContext.getCurrentInstance().getExternalContext().encodeResourceURL(report);
try{
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
FacesContext.getCurrentInstance().responseComplete();
} catch(Exception e){
}
}
Finally, the error message:
The report file : C:Program FilesIBMWebSphereAppServerCommunityEditionrepositoryinfomatereportviewer1.0.1reportviewer-1.0.1.carhttp:localhost:8080Reports/CanteenSalesDetail.rptdesign does not exist or contains errors.
Now, from the error message, it looks like the WORKING_FOLDER_ACCESS_ONLY setting is being ignored. Is it my version? I use BIRT 2.5.2
JasonW
Can you post the final url from:
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
Jason
javaguy
/POSReports/frameset?__report=CanteenSalesDetail.rptdesign
JasonW
I thought you were putting the whole url to the report in. It should have been something like:
/POSReports/frameset?__report=
http://server:/port/ap/CanteenSalesDetail.rptdesign
instead of like:
/POSReports/frameset?__report=CanteenSalesDetail.rptdesign
Jason
javaguy
I put it in the web.xml file:
<context-param>
<param-name>BIRT_VIEWER_WORKING_FOLDER</param-name>
<param-value>
http://localhost:8080/Reports/</param-value>
;
</context-param>
That way I don't need it in the URL. Do I?
JasonW
I do not believe the working folder can be a url.
javaguy
OK, I took the working folder out of the web.xml file. Now the viewer is back to stripping the url out from the front of the report name and I still get the error.
JasonW
I just tried this with 2.5.2 and I do not see the viewer stripping out the url.
javaguy
The only part of the url it strips out is the part I added in my method. I don't understand how it can do that. Did you use the setings I showed in my web.xml?
JasonW
I used the default web.xml settings.
javaguy
which uses the default of true for WORKING_FOLDER_ACCESS_ONLY.
Where are your reports? In the viewer project, or in another project?
JasonW
To do a simple test I deployed a 2.5.1 viewer and a 2.5.2 viewer. I then added a report to the root of the 2.5.1 viewer. I launched the 2.5.2 viewer and added the report url like:
__report=
http://localhost:8080/2.5.1/mytestreport.rptdesign
This worked. I verified that the mytestreport.rptdesign was only located in the 2.5.1 viewer project.
Jason
javaguy
See, that's the problem. I don't want my reports to be in a viewer project. I want them in a separate simple web project so they are easier to deploy. If I have them in the viewer project, I have to deploy the viewer every time I create a new report, which takes a very long time.
Keep in mind, the way our publishing process works, we don't just copy and paste files into the wasce file system. We deploy them in WAR files. It's easier to manage versions this way.
I don't understand why it won't work the way I want it to. I mean, there is an option in the eclipse plugin to create a report project, which is separate from the viewer project, so why can't I put my reports in a separate web project?
JasonW
The reports did not need to be in a viewer project. I also ran the test with a report copied to a standard web app deployed to tomcat.
Jason
javaguy
OK, so what is wrong? Apparently my installation and configuration match yours, so why is mine not working right?
JasonW
I am not certain why this is happening. Can you try on your desktop with tomcat like I did (Just as a test)?
javaguy
That's what I've been doing. I HAVE deployed a report in a separate web project, using eclipse, which uses a wasce server, which is Tomcat. I don't know what else to do!
JasonW
One thing that is different is that I am deploying mine outside of Eclipse. I ran a test where I had a simple app that had a reports directory. I warred it and deployed to tomcat with the 2.5.2 viewer and entered this url:<br />
<a class='bbc_url' href='
http://localhost:8080/2.5.2/frameset?__report=http://localhost:8080/WebReport/Reports/TopNPercent.rptdesign'>http://localhost:8080/2.5.2/frameset?__report=http://localhost:8080/WebReport/Reports/TopNPercent.rptdesign</a><br
/>
<br />
And this worked. Any chance you have netmeeting or skype?<br />
<br />
Jason
stilden
I think I understand what's happening, but I'm not sure that you have any alternative. Let me first ask a couple of questions:
1) Are your reports themselves being deployed within a *.war file?
2) Also, is there any special project setting that would duplicate the actual rptdesign file in an actual file path on your development machine?
If the answer to #1 is yes, I believe you may be out of luck unless you customize some stuff or change your deployment methods. You could even utilize a Tomcat or other server to 'web deploy' them so that you could still publish your BIRT viewer project normally, but access of the actual rptdesign files is done via the web from that application.
The reality is that you simply need a viable path for the viewer to find the file at, and I'm really not sure that the viewer supports war file path extraction. You could possibly use the WebSphere actual deployed directories which extract the war file and house the files exploded, but the path is involved and may not be allowed in your environment as it reveals the WebSphere installation path on the server and that's usually a security breach.
Steve
javaguy
Yes, we do deploy our projects as WAR files. I guess we'll have to live with it the way it is.