Export a PDF file from a servlet ATG: IllegalStateException: response already committed
Question of high level
"When a servlet in my servlet pipeline ATG wrote a PDF document to the HTTP response output stream, well that the PDF file is delivered to the browser of the client user successfully, an error is recorded on the server: Servlet failed with Exception java.lang.IllegalStateException: response already committed." Why does this happen?
Details
My ATG 10.1.2 application needs to be able to generate and return a PDF document to the client browser when the user clicks on a particular button on the site.
Although I don't know if it is a best practice of the ATG, the approach that I landed on this is to insert a new custom servlet, 'PdfExportServlet', in the pipeline of servlet ATG. The PdfExportServlet, for the applications it considers PDF application and decides to manage, generates the PDF content (using Jasper reports engine) and writes the PDF content to the HTTP response output stream. Here's the relevant part of the code:
response.setContentType("application/pdf");
// (... The code that generates a JasperPrint object with the PDF content...)
final byte [] pdfBinaryContent = JasperExportManager.exportReportToPdf (jasperPrint);
response.setContentLength (pdfBinaryContent.length);
final ServletOutputStream outputStream = response.getOutputStream ();
outputStream.write (pdfBinaryContent);
outputStream.flush ();
outputStream.close ();
It works very well, and the PDF file is displayed in the client browser. However, a mistake is also recorded in the log file of the application on the server:
[< WL-101020 > < [path of the module: shop ServletContext@1369332778[app:storeFront: / shop spec-version: 2.5]] Servlet failed with Exception
java.lang.IllegalStateException: response already committed
at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1631)
at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:637)
at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:602)
at weblogic.servlet.FileServlet.findSource(FileServlet.java:269)
at weblogic.servlet.FileServlet.doGetHeadPost(FileServlet.java:191)
at weblogic.servlet.FileServlet.service(FileServlet.java:173)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
to weblogic.servlet.internal.StubSecurityHelper$ ServletServiceAction.run (StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
at atg.servlet.GenericFilterService.doFilterChain(GenericFilterService.java:621)
....
One frustrating thing about this error that had made it difficult to solve, is that it does not occur on my PC; local development this log message appears only when the application is running on one of our servers of pre-production or production. This made try scan multiple possible solutions that are problematic, because every change to the code requires a fresh deployment to our shared, pre-production server which takes time.
I tried the following variations on the above code, or resulting in a change in the manifestation of the question (the error message that appears in the log):
- After the call to outputStream.close (), on the theory that it may help prevent the servlets downstream demand has already been posted, and no other attempts to modify and validate the request should be made added a call to response.flushBuffer ().
- Removed calls to outputStream.flush () and outputStream.close (), on the theory that some members of servlet (TailPipelineServlet?) downstream pipeline may be responsible for closing the outputStream, and try to do it prematurely was responsible for the mistake.
I also have so far have not found anything relevant in the documentation of the ATG/Oracle may provide a clue as to what is happening here, or what general best practices about having a custom servlet in the ATG pipeline that generates output to outputStream of the answer.
All the tips about the cause of this error, or what needs to be done to resolve this would be welcome!
Thank you
-Jon
I figured out the call to outputStream.write () is originally the HttpServletResponse to commit, because the size of the buffer of the ServletResponse is less than the size of my PDF data Byte. Reference: ServletResponse (Java EE 6)
However, when I let my servlet to return with the HttpServletResponse in a State that is not validated, the client browser gets served a 404 instead of the PDF data. I am currently looking into this issue.
Tags: Oracle Applications
Similar Questions
-
I have a special mix CMYK for a bcard in Indesign. When I export the pdf file that the CMYK mix has changed just started today 1.13.15 Running Yosemite 10.10.1 all help to what to look for would be greatly appreciated.
You are mixing color profiles a-place, or document workspace does not match the destination to export space is incompatible.
-
Firstly - I work in InDesign CC 2015.
My problem is, I had this 10 page document, which, on every page, shows an object that must be in PDF format - but do not print. I made this object into a button and unchecked "Printable". On top of this object, I made 10 hyperlinks (separate layer) that point to the page 1-10.
When you export the document and I use the interactive PDF format , works ' show nonprinting object but do not print ' well, BUT hyperlinks don't. If I uncheck the "layer of nonprinting objects" in the file PDF, then hyperlinks work, but the problem now is that the nonprinting objects are invisible...
When you export the document and I use a PDF to print the "unprintable object show but do not print" does not work BUT the hyperlinks don't...
I put hyperlinks to post a link to pages and also tried the link to the anchor text. No difference.
So my question is: How to export a PDF file to make nonprinting objects show but don't print not AND hyperlinks on the top of the page work at the same time?
Thank you
Mette from Denmark
I swapped my links to the buttons - AND NOW IT WORKS; (o)
-
I can't export a PDF file to Word, there is an error in access to the service
I can't export a PDF file to Word, there is an error in access to the service
!
Hi florac81095806,
If you use ExportPDF go in drive, please make sure you have Acrobat Reader DC, as you can no longer access the service of earlier versions of the player. You can download the CD from this page: https://get.adobe.com/reader.
Best,
Sara
-
Create PDF/A compliant PDF files from InDesignCS6 files
I apologize if this appears twice; I thought I had posted about 45 minutes ago, but do not see it. I was invited to generate PDF/A (1A or 1B) compliant files for archive accessible from my v8 InDesign CS6 files. PDFs exported directly from conversion fail Indd in Acrobat Pro 10.1.4 or root of the tree structure and other things that I have not the time to become an expert (I have other work!). I am currently printing .ps to co-operate and through these files distill 10.1.4. The results do not compliance due to one thing after the other. currently no RGB and CMYK images. I now use the generated PDF by Distiller by conversion of Acrobat with my fingers crossed.
Is there a better, easier, faster and more efficient way to do it? Please?
I suspect you will need to get advice in the Acrobat forums. The vast majority of us never creates PDF/A file. try this forum:
-
How to open the pdf files from hotmail.
OMG no body can help with this question, how to open the pdf files from hotmail
OMG no body can help with this question, how to open the pdf files from hotmail
Told you that you need Adobe Reader, which is designed to open pdf files?
Download Adobe Reader:
-
does not connect to allow to export a PDF file to a Word document
does not connect to allow to export a PDF file to a word document
Try to do it here: https://cloud.acrobat.com/exportpdf
-
How to download a PDF file from my pc to cloud document adobe?
How to download a PDF file from my pc to cloud document adobe?
Hi Tania Leonardo.
Please see the steps in this KB doc for help: manage and work with the files in Adobe Document cloud
Let us know if you need help.
Kind regards
Meenakshi
-
Cannot open a pdf file from the website of immigration canada. Gets a message - you need a later version of the same player after update still not working
10 Windows Internet Explorer with the Acrobat Reader plugin is available.
-
RE: ORDER NUMBER: ADO18068065
I just bought your program Adobe Export PDF but does not - Adobe allows me to capture what PDF I want to export - but won't let me DO NOT convert the file (the window to see where the PDF export is grayed out and I can't enter anything). Can I entered an incorrect email when I signed firstly for the export of Adobe program ([email protected] INSTEAD of Correct e-mail address: [email protected] could you go to see if the order went through because your window opens each time I try to export a PDF file to WORD asking me to buy the program Adobe export again. )
Thanks - Pls email me at: [email protected] with your answer.
Make sure that you have installed the last DC of Adobe Acrobat Reader Acrobat Reader DC Learn & Support to use the service to export it to PDF help of Acrobat Reader | Export PDF to Acrobat Reader DC.
You can also use this service online at https://cloud.acrobat.com/exportpdf
Let me know if you have still any problem?
Kind regards
Nicos
-
How to create a PDF file from the Clipboard in Adobe Acrobat Reader ms?
Is it possible to create a PDF file from the Clipboard in Adobe Acrobat Reader ms?
No, Acrobat Reader cannot create PDF files.
-
Is it possible to use Adobe Pro to create a PDF file from an e-mail item in Outlook 2013?
Is it possible to use Adobe Pro to create a PDF file from an e-mail item in Outlook 2013? We used this feature in Outlook 2010 and just converted in 2013 Outlook, but it doesn't seem to be available any longer?
Are there plans to make available for Outlook 2013 or 2016?
Hi maryga0922,
You must have Acrobat installed compatible version that would work with Outlook 2013.
Otherwise you will not see the Acrobat tab in Outlook. Web browsers and applications of PDFMaker
This is the reason why I asked for the version of Acrobat is installed on your system.
Kind regards
Nicos
-
Is it possible to export a pdf file, so it conceives as extends on a computer desktop, but as unique pages on a mobile/tablet device?
Hey chrisr60180361,
I'm sorry this is not possible.
You will need to save another copy of the PDF file with the unique page for mobile devices.
Kind regards
Nicos
-
When I export my PDF file to Word, I lose the formatting?
Why am I losing my page/font formats and spacing when I export my PDF file to Word?
It would be useful to know the operating system and the version of Acrobat. When you export, the registration screen has a settings option that includes retain format (creates a lot of text boxes) or flow. There are also options for OCR and graphics in the settings. If the PDF has strange fonts (or non-system), they will be not recorded and Acrobat will try a better idea on an appropriate policy.
-
Bloat pdf file from Word Macintosh?
When you create a pdf file of a Word on a Mac file, the file size becomes huge. The same file converted to PDF using Acrobat on a Windows machine results in a much smaller file. For example, I wrote a two-page letter that included several photos:
Original file size: 12.9 MB
PDF created by Acrobat on Windows PC: 227KO
PDF created by Acrobat on Mac (OSX10.10): 61.1 MB
PDF created by Mac: 61.2 MB
What the hell is happening?
Thank you.
Maybe you can tell us exactly how you created the PDF file from a Word under MacOS document?
You have installed Acrobat? If so, which version?
Word you used the file => save as-online PDF
or have you used leader-online Print-online PDF => record in PDF...
or have you used -Online Print-online PDF File => Save as Adobe PDF...?
If you do not have Acrobat installed such that used the -Online Print-online PDF file => save as Adobe PDF... option, all bets are off.
-Dov
Maybe you are looking for
-
HP-15f039wm: need help to find the driver
I got lost. need help finding the (USB) Universal Serial Bus controller. would be very grateful for help.
-
Good afternoon! My iphone 6s this drain the battery. The battery is only lasting six hours without use. What should I do to solve this problem. NOTE: Sorry I'm using google translator.
-
HP 6700 Premium: Behavior strange scan
Machine has worked perfectly for almost two years. It still prints perfectly. BUT, I just returned from a two week trip, & now, whenver I go to scan, he asked me to do an installation of the printer, and I have to re - enter the router IP address e
-
Variants: How to assign a new value without alteration/losing its attributes?
Hello I work with data varying with some metadata stored as attributes. Data values change frequently, but the metadata values are fairly constant. I am looking for a way to update the value of a Variant while preserving its attributes (or equivalent
-
Cannot delete the files read-only on display
Hello I copied files from my PC to the view, but when they were on the PC, they were marked read-only. Now, I found that I can't remove them from the sandisk as it says that they are read-only. How do I change the properties of the files so I can del