aspose file tools*
The moose likes Other Application Frameworks and the fly likes Closing Buffer Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Closing Buffer Error" Watch "Closing Buffer Error" New topic
Author

Closing Buffer Error

Vinayak More
Greenhorn

Joined: Mar 12, 2013
Posts: 1
Hi Friends,

I'm getting Closing Buffer Error . I read lot of forums but unable to resolve it. Could you please help me to resolve it..I have attach comple code

2013-03-12 05:46:34,160 120563 ERROR WebResponse: Unable to redirect to: ?wicket:interface=:2:36::::, HTTP Response has already been committed.
2013-03-12 05:46:34,302 120705 ERROR WicketFilter: closing the buffer error
java.lang.IllegalStateException: Committed
at org.mortbay.jetty.Response.resetBuffer(Response.java:1023)
at org.mortbay.jetty.Response.sendRedirect(Response.java:428)
at org.apache.wicket.protocol.http.WebResponse.sendRedirect(WebResponse.java:299)
at org.apache.wicket.protocol.http.WebResponse.redirect(WebResponse.java:250)
at org.apache.wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:67)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:502)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at com.uprr.ui.wicket.components.infrastructure.RicolaWicketFilter.doFilter(RicolaWicketFilter.java:25)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

private void addPrintButton11() {
Button printButton = new Button("printButton11") {
private static final long serialVersionUID = 1L;

@Override
public void onSubmit() {
final List<SystemGeneralOrderSearchModel> list = new ArrayList<SystemGeneralOrderSearchModel>(0);
// Error Message if non of the Check box selected
if (getSgoGrid().getSelectedItems().isEmpty()) {
error(new ResourceModel("error_service_unit_checkbox_select").getObject().toString());
getFeedbackPanel().setShowErrorLink(false);
getFeedbackPanel().setEscapeModelStrings(false);
// /target.addComponent(getFeedbackPanel());
} else {
// Adding selected records in the list
for (final SystemGeneralOrderSearchModel systemGeneralOrderSearchModel : getSgoGrid().getSelectedItems()) {
// Skip Sys. SI. 0 record as a part of Merging
if (!RCRFEnum.SSI_0.value().equalsIgnoreCase(systemGeneralOrderSearchModel.getOrderCategory())) {
list.add(systemGeneralOrderSearchModel);
}
}
new ViewSelectedEffectiveSystemGeneralOrder(list);
}
}
};

getSgoGroupBox().addOrReplace(printButton);
}


private void viewMergedPDF(List<SystemGeneralOrderSearchModel> list)
{
ByteArrayOutputStream byteArrayOutputStream = null;
String fileName = new ResourceModel("effectiveMergedSystemGeneralOrder").getObject().toString();
OutputStream outs = null;
byteArrayOutputStream = pdfMergeService.mergeSelectedPDFUsingWindow(list);
// To open PDF Dialog box
if (byteArrayOutputStream != null) {
try {
WebResponse response = (WebResponse) getRequestCycle().getResponse();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition","attachment;filename="+fileName+"");
outs = response.getOutputStream();
outs.write(byteArrayOutputStream.toByteArray());
outs.flush();
outs.close();
outs = null;
} catch (Exception ex) {
LOGGER.error("Exception occured while opening PDF :", ex);
}
finally {
if (outs != null) {
try {
outs.flush();
outs.close();
}
catch (Exception e) {
LOGGER.error("Error occured in viewMergedPDF Finally Block", e);
}
}
}
}
}



public ByteArrayOutputStream mergeSelectedPDFUsingWindow(List<?> list) {
final ByteArrayOutputStream baos= new ByteArrayOutputStream();
StringBuilder fileName = new StringBuilder();
Document document = new Document();
PdfCopy copy = null;
int i = 1;
//Server Path
if (ERTHelper.isLocalMode()) {
fileName.append(ERTEnum.LOCAL_DRIVE_PATH.value());
} else {
fileName.append(ERTEnum.PDF_PATH.value());
}

try {
copy = new PdfCopy(document, baos);
document.open();

for (Object object : list) {
// Bulletins Records
if (object instanceof Bulletin) {
Bulletin bulletin = (Bulletin) object;
if (i == 1) {
fileName.append(ERTEnum.APPEND_B_HYPEN_TO_FILE_NAME.value());
fileName.append(bulletin.getServiceUnitName().replaceAll(" ", ""));
}
// Merging all PDF Files
mergeFiles(fileName.toString()+(bulletin.getCategoryId()+ERTEnum.PDF_FILE.value()), copy);
i = 0;
}
// System General Order Records
else if (object instanceof SystemGeneralOrderSearchModel) {
SystemGeneralOrderSearchModel systemGeneralOrder = (SystemGeneralOrderSearchModel) object;
mergeFiles(fileName.toString()+getPDFFileName(systemGeneralOrder.getOrderCategory()), copy);
}
}


} catch (Exception e) {
LOGGER.error("Error occured MergeSelectedPDF ", e);
}

document.close();
return baos;
}
 
 
subject: Closing Buffer Error