HTML to PDF / DOCX / RTF Java converter library Forums PD4ML Forums Technical questions / Troubleshooting relative URL to a servlet in the “img”-tag throws a MalformedURLException

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #36718

    I am migrating from V3 to V4. Relative paths within an tag, such as.
    <img src="/servlet/ImageServlet?picid=2730100&width=310" />
    which still worked in V3, now throw an exception:

    java.net.MalformedURLException: SRVE0238E: Ressourcenpfade müssen einen vorangestellten Schrägstrich enthalten.
    at com.ibm.ws.webcontainer.webapp.WebApp.getResource(WebApp.java:2453)
    at com.ibm.ws.webcontainer.webapp.WebApp.getResourceAsStream(WebApp.java:2419)
    at com.pd4ml.cache.ServletResourceProvider.getResourceAsStream(y:1928)
    at com.pd4ml.ResourceProvider.getResourceAsBytes(y:2080)
    at com.pd4ml.cache.e.new(y:404)
    at com.pd4ml.cache.e.return(y:380)
    at com.pd4ml.cache.FileCache.getImage(y:375)
    at com.pd4ml.html.doc.render.ub.<init>(y:2554)
    at com.pd4ml.html.doc.render.to.h.new(y:1048)
    at com.pd4ml.html.doc.render.to.k.super(y:968)
    at com.pd4ml.html.doc.render.to.k.super(y:2161)
    at com.pd4ml.html.doc.render.to.f.super(y:149)
    at com.pd4ml.PD4ML.writePDF(y:2154)
    at com.pd4ml.PD4ML.writePDF(y:3327)
    at com.pd4ml.taglib.PD4MLTransformerTag.render(y:2346)
    at com.pd4ml.taglib.PD4MLTransformerTag.doEndTag(y:2781)

    Is there a solution or workaround for this?

    #36731

    It looks like an issue of web application configuration: for some reason the servlet resource provider does not recognize /servlet/ prefix as a name of local web application.

    Did you place the v4 pd4ml*.jar in WEB-INF/lib or is it in the common lib/ directory? Since the new taglib JSP classes are in pd4ml*.jar, the location of the JAR (which determines which classloader is used) can be relevant.

    For a smoother transition of JSPs from PD4ML v3 to v4, we recommend that you leave the JSPs as they are and store pd4ml_tl.jar from v3 in WEB-INF/lib. Generally, taglib v3 works well with PD4ML v4.

    #36776

    I have switched to V4 and no longer use the V3 library. I don’t think it is a path problem of the pd4ml.jar either, because the
    library is found, otherwise the whole PDF printing would not work. I have included the HTML page for PDF printing via a JSP page
    and the taglib <%@ taglib uri="/WEB-INF/tlds/pd4tl.tld" prefix="pd4ml" %> and use the “transform”-tag. As I said, it still worked without problems in V3. In V4, something must have changed in the handling of the “img”-tag.

    #36777

    Judging from the error stack, the PD4ML tries to load the image as a file, which cannot succeed with a servlet:

    at com.pd4ml.cache.ServletResourceProvider.getResourceAsStream(y:1928)
    at com.pd4ml.ResourceProvider.getResourceAsBytes(y:2080)
    at com.pd4ml.cache.e.new(y:404)
    at com.pd4ml.cache.e.return(y:380)
    at com.pd4ml.cache.FileCache.getImage(y:375)

    #36783

    > I don’t think it is a path problem of the pd4ml.jar either, because the library is found, otherwise the whole PDF printing would not work.

    The problem is not in finding of pd4ml.jar
    The libraries from common lib/ and WEB-INF/lib/ are loaded by different classloaders. Libraries loaded from common lib/ may not see local web application resources.

    #36925

    Thank you very much for your answer. I have moved the pd4ml-4.0.16.jar from the application/lib directory to the WEB-INF/lib.
    Unfortunately the result is the same! The same exception again and again:

    java.net.MalformedURLException: SRVE0238E: Resource paths must contain a preceding slash.
    at com.ibm.ws.webcontainer.webapp.WebApp.getResource(WebApp.java:2453)
    at com.ibm.ws.webcontainer.webapp.WebApp.getResourceAsStream(WebApp.java:2419)
    at com.pd4ml.cache.ServletResourceProvider.getResourceAsStream(y:1928)
    at com.pd4ml.ResourceProvider.getResourceAsBytes(y:2080)

    #37255

    Hi! Before we analyzed and fixed the issue you could try to use a hybrid solution: pd4ml_tl.jar from v3 + pd4ml.jar from v4
    This combination is used by a number of our clients because porting of JSPs utilize PD4ML v3 taglib is not always possible.

    #37501

    The libraries from common lib/ and WEB-INF/lib/ are loaded by different classloaders. Libraries loaded from common lib/ may not see local web application resources.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.