HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › pd4ml:transform and "Didn’t meet stated Content-Length"
- This topic has 2 replies, 3 voices, and was last updated Jun 14, 2012
18:30:29 byAnonymous.
-
AuthorPosts
-
June 12, 2012 at 16:44#26737
UPDATE 06.14.2012
Here is the most relevant post on stackoverflow. I don’t have the pd4ml source to look into this:
http://stackoverflow.com/questions/1664996/weblogic-exceeded-stated-content-length-errorAgain the same code works fine on other J2EE servers, it’s specific to web logic and the workaround is to stop setting the content length. Does PD4ML set the content length?
After upgrading to Oracle 11g Weblogic from Oracle’s OC4J 10g based application server I’m encountering an issue with a page we use pd4ml to generate a PDF. the error message is listed below. This error seems to be encountered by WebLogic users in general when outputting a response that is actually a PDF. Has anyone else experienced this and found a solution?
<Jun 12, 2012 12:21:54 PM EDT> <Error> <HTTP> <BEA-101083> <Connection failure. java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '94944' bytes instead of stated: '86669' bytes. at weblogic.servlet.internal.ServletOutputStreamImpl.ensureContentLength(ServletOutputStreamImpl.java:457) at weblogic.servlet.internal.ServletResponseImpl.ensureContentLength(ServletResponseImpl.java:1448) at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1530) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1498) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) Truncated. see log file for complete stacktrace > <Jun 12, 2012 12:21:54 PM EDT> <Error> <HTTP> <BEA-101104> <Servlet execution in servlet context "ServletContext@3499281[app:taa module:taa path:/taa spec-version:2.5]" failed, java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '94944' bytes instead of stated: '86669' bytes.. java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '94944' bytes instead of stated: '86669' bytes. at weblogic.servlet.internal.ServletOutputStreamImpl.ensureContentLength(ServletOutputStreamImpl.java:457) at weblogic.servlet.internal.ServletResponseImpl.ensureContentLength(ServletResponseImpl.java:1448) at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1530) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1498) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) Truncated. see log file for complete stacktrace >
JSP:
<%@ taglib uri="https://pd4ml.com/tlds/pd4ml/2.6" prefix="pd4ml"%><br /> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %><br /> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><br /> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %><pd4ml:transform screenWidth="1000" pageFormat="LETTER" pageOrientation="landscape" pageInsets="24,36,24,36,points"><br /> <html><br /> <head><br /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /><br /> <title><br /> Teacher Authorization and Authentication<br /> </title><br /> <link href="${pageContext.request.contextPath}/include/css/style.css" rel="stylesheet" type="text/css" media="screen"/><br /> <link href="${pageContext.request.contextPath}/include/css/display-tag.css" rel="stylesheet" type="text/css" media="screen"/><br /> <link rel="icon" type="image/png" href="${pageContext.request.contextPath}/favicon.ico" /><br /> </head><br /> <br /> <body><br /> <div id="wrapper"><br /> <div id="topheader"><br /> <div id="logo"></div><br /> <h2 class="title"><tiles:getAsString name="title" /></h2><br /> </div><br /> </div><br /> <div style="clear: both;"></div><br /> <div id="page"><br /> <div id="print_content_full"><br /> <div style="clear: both;"></div><br /> <tiles:insertAttribute name="body" /><br /> </div><br /> <br /> <div style="clear: both;"></div><br /> </div><br /> <br /> <br /> </body><br /> </html></pd4ml:transform>June 14, 2012 at 18:09#29024> Does PD4ML set the content length?
Of course, yes. PDF is binary data, so it always makes sense to set it.
The problem, you faced with, most probably caused by an undesired text encoding conversion, applied to PDF bytes. For example Latin-1 to UTF-8 – that explains why the actual data amount has grown. Obviously UTF-8 became a default file encoding after you upgraded to Oracle 11g.
What to do?
1. Try to run Oracle with file.encoding set to the same value as it was in previous installation
2. If #1 is not possible, try to add encoding=”UTF-8″ or encoding=”default” attribute to<pd4ml:transform>Also there are 3 new line characters before
<pd4ml:transform>– they will be sent before PD4ML started to send PDF bytes. It is a good idea to remove them.June 14, 2012 at 18:30#29025Thank you. Setting the encoding to default fixed it. My point about the call to setContentLength is many forum users, including the sample code I linked to on stackoverflow.com showed a solution involved removing calls to setContentLength. I knew that was not an option for me because the call would be in the pd4ml. So I was hoping to find a solution that didn’t involve removing calls to setContentLength.
-
AuthorPosts
The forum ‘Troubleshooting’ is closed to new topics and replies.
