#1 Report's linked resources are not being rendered

v1.0-RC
closed
Build (2)
5
2012-10-10
2010-02-04
No

Need for an enhanced "FileResolver"/"HyperlinkProducer" implementations. Reports which has linked resources (images, html, etc) render too many "<null>" tags and uris are not being properly configured.

Features to implement are (but not limited to) the following:
- Recognize classpath resouces requested from JasperReports without the "classpath:" prefix
- Recognize partial URI mappings with query string
- Identify the different cases where HyperlinkProducer is invoked and avoid rendering anchors when they are not needed

Discussion

  • Alonso Dominguez

    New resource resolver algorithm has been implemented. HyperlinkProducer has been disabled in order to testing the different drawbacks of using the provided implementation bundled inside JaspeReports when generating partial urls and resolving the resources.

    Please, chect out new code from the Subversion repository. Any feedback from beta testers would be greatly appreciated.

     
  • Jeff Headley

    Jeff Headley - 2010-02-23

    I got the latest and tried it with a simple report created with iReport 3.7.1 and selected the "Coffee Landscape" template which has 2 embedded images. iReport exported successfully to html and it displayed correctly. However, in my web application I received the below stack trace. The images are in the same folder as the .jasper file. My tag looks like:

    <jr:report path="/reports/userInfo.jasper" format="html" width="770px" height="600px" dataSource="jndiDataSource"/>

    My reports without images display and export correctly.

    I received the below stack trace:

    Feb 23, 2010 2:55:12 PM com.sun.faces.lifecycle.Phase handleBeforePhase
    WARNING: JSF1053: (Listener: net.sf.jasperreports.jsf.ReportPhaseListener.beforePhase(), Phase ID: RENDER_RESPONSE 6, View ID: /jasperreportsjsf.xhtml) Exception thrown during phase-listener execution: net.sf.jasperreports.jsf.fill.FillerException: net.sf.jasperreports.engine.JRException: Byte data not found at location : coffee.jpg
    14:55:12,301 WARNING [lifecycle] JSF1053: (Listener: net.sf.jasperreports.jsf.ReportPhaseListener.beforePhase(), Phase ID: RENDER_RESPONSE 6, View ID: /
    jasperreportsjsf.xhtml) Exception thrown during phase-listener execution: net.sf.jasperreports.jsf.fill.FillerException: net.sf.jasperreports.engine.JRException: Byte data not found at location : coffee.jpg
    Feb 23, 2010 2:55:12 PM com.sun.faces.lifecycle.Phase handleBeforePhase
    WARNING: net.sf.jasperreports.jsf.fill.AbstractSQLFiller.doFill(AbstractSQLFiller.java:120)
    net.sf.jasperreports.jsf.fill.AbstractFiller.fill(AbstractFiller.java:107)
    net.sf.jasperreports.jsf.renderkit.AbstractReportRenderer.encodeContent(AbstractReportRenderer.java:84)
    net.sf.jasperreports.jsf.renderkit.EmbedRenderer.encodeContent(EmbedRenderer.java:38)
    net.sf.jasperreports.jsf.component.html.HtmlReport.encodeContent(HtmlReport.java:326)
    net.sf.jasperreports.jsf.ReportPhaseListener.beforePhase(ReportPhaseListener.java:103)
    com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
    org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
    org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    com.terida.classoft.filters.UserActivityLoggingFilter.doFilter(UserActivityLoggingFilter.java:116)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:613)

    14:55:12,302 WARNING [lifecycle] net.sf.jasperreports.jsf.fill.AbstractSQLFiller.doFill(AbstractSQLFiller.java:120)
    net.sf.jasperreports.jsf.fill.AbstractFiller.fill(AbstractFiller.java:107)
    net.sf.jasperreports.jsf.renderkit.AbstractReportRenderer.encodeContent(AbstractReportRenderer.java:84)
    net.sf.jasperreports.jsf.renderkit.EmbedRenderer.encodeContent(EmbedRenderer.java:38)
    net.sf.jasperreports.jsf.component.html.HtmlReport.encodeContent(HtmlReport.java:326)
    net.sf.jasperreports.jsf.ReportPhaseListener.beforePhase(ReportPhaseListener.java:103)
    com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
    org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
    org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
    org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    com.terida.classoft.filters.UserActivityLoggingFilter.doFilter(UserActivityLoggingFilter.java:116)
    org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:613)

     
  • Jeff Headley

    Jeff Headley - 2010-02-23

    I was able to get it working by placing the images in different locations in my project. So originally iReport placed the images along with the .jasper file in <my_war_root>/reports. I tried moving the images to different places and eventually I tried <my_war_root>/WEB-INF/classes and the html exporter completed successfully. No images displayed on the page, but the rest of the report was there and looked correct. PDF, Excel, and Word exports all had the images included and looked correct.

     
  • Alonso Dominguez

    thanks a lot for your feedback, future release will provide a FAQ document including your this specific issue

     
  • Alonso Dominguez

    mmm... another thing: Did you tried to put your resources at the same folder than the faces' view which embeds the report? I tried something like this and it seemed to work well.

    I'm wondering how could be the more suitable behavior when dealing with relative paths:
    1. resolve resource relative to the report file ??
    2. resolve resource relative to the faces view
    3. resolve resource from the classpath

     
  • Nobody/Anonymous

    I went back and tried putting the page in the reports folder along with the .jasper file and the images and I got the sam error as before.
    Exception thrown during phase-listener execution: net.sf.jasperreports.jsf.fill.FillerException: net.sf.jasperreports.engine.JRException: Byte data not found at location : coffee.jpg

    To me I think it would be best to resolve linked images and similar items relative to the report file so that I can place the report and its resources somewhere in my web app project yet still be able to open up and work with the report in the iReport tool without needing to move files around.

     
  • Alonso Dominguez

    I have enabled the plugin to resolve resources relative to the report file. This should allow working with application sources and report sources (iReport generated) without any intermediary steps. New sources are available at Suversion repository.

     
  • Jeff Headley

    Jeff Headley - 2010-03-23

    I got the latest from svn to try it out, but Maven is reporting that two jars could not be found. Log pasted below:


    [ERROR]BUILD ERROR

    Failed to resolve artifact.

    Missing:

    1) net.sf.jsf4portlets:jsf4portlets:jar:1.0-alpha-2

    Try downloading the file manually from the project website.

    Then, install it using the command:
    mvn install:install-file -DgroupId=net.sf.jsf4portlets -DartifactId=jsf4portlets -Dversion=1.0-alpha-2 -Dpackaging=jar -Dfile=/path/to/file

    Alternatively, if you host your own repository you can deploy the file there:
    mvn deploy:deploy-file -DgroupId=net.sf.jsf4portlets -DartifactId=jsf4portlets -Dversion=1.0-alpha-2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

    Path to dependency:
    1) net.sf.jasperreports:jasperreports-jsf:jar:1.0-RC
    2) net.sf.jsf4portlets:jsf4portlets:jar:1.0-alpha-2

    2) jasperreports:jasperreports:jar:3.7.1

    Try downloading the file manually from the project website.

    Then, install it using the command:
    mvn install:install-file -DgroupId=jasperreports -DartifactId=jasperreports -Dversion=3.7.1 -Dpackaging=jar -Dfile=/path/to/file

    Alternatively, if you host your own repository you can deploy the file there:
    mvn deploy:deploy-file -DgroupId=jasperreports -DartifactId=jasperreports -Dversion=3.7.1 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

    Path to dependency:
    1) net.sf.jasperreports:jasperreports-jsf:jar:1.0-RC
    2) jasperreports:jasperreports:jar:3.7.1


    2 required artifacts are missing.

    for artifact:
    net.sf.jasperreports:jasperreports-jsf:jar:1.0-RC

    from the specified remote repositories:
    central (http://repo1.maven.org/maven2),
    maven2-repository.dev.java.net (http://download.java.net/maven/2),
    maven1-repository.dev.java.net (http://download.java.net/maven/1)

     
  • Alonso Dominguez

    I upgraded the JasperReports version to provide better features linked to filling and exporting. The plugin now needs to be compiled with JasperReports 3.7.1 and that version it's not currently available at Maven 2 central repository, you will need to download it by yourself and invoke the mvn install:install-file goal to install that version into your local repository. However, you don't need to use that version within your application, you can still work with the version you're using.

    Please, note also that, to not reinvent the wheel, I added a dependency with Apache Commons IO, which helps dealing with the report resources path names.

     
  • Nobody/Anonymous

    That worked, thanks Alonso. Do you happen to know where I can get the jsf4portlets that this project is looking for. Maven was failing to find the jsf4portlets jar so I went and downloaded it from http://jsf4portlets.sourceforge.net/web/download.html

    Only the compiler is now complaining that the javax.portlet.faces.Bridge class does not have the .VIEW_ID constant so I must have added the wrong version to my repository.

     
  • Jeff Headley

    Jeff Headley - 2010-03-30

    Sorry, was not logged in. That comment below was from me.

     
  • Alonso Dominguez

    Thanks a lot for your feedback.

    The current problems that you're facing come from the fact that your downloaded an incorrect version of JSF 4 Portlets. Don't worry, it's not your fault, it's mine :). JSF 4 Portlets is a project of mine which aims to implement JSR-301 and JSR-329 (Porlet Bridge for JavaServer Faces). This plugin requires the later spec to work correctly and the compiler error you're receiving is because the constant 'VIEW_ID' was added to the Bridge interface in JSR-329.

    No problem, you can obtain the sources for the JSR-329 implementation from a JSF 4 Portlets branch: https://jsf4portlets.svn.sourceforge.net/svnroot/jsf4portlets/jsf4portlets-2.0. I'm currently pushing to release a beta version of that branch, my plan is to publish that release before the release candidate of this plugin so I hope it will be available soon but since you just want to compile the plugin code I think that using the subversion code will be enough.

    Good look and many thanks for your efforts with this project.
    Alonso

     

Log in to post a comment.