을 폐쇄 :때 java.io.IOException : UT010029은 : 스트림 오류 아래 Resove하는 방법
ERROR [com.test.filter.AuthenticationFilter] (default task-6) displayUpdateUser:Error occurred while displaying the Update User page.: java.io.IOException: UT010029: Stream is closed
at io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:136)
at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:167)
at org.springframework.web.servlet.view.AbstractView.writeToResponse(AbstractView.java:468)
at org.springframework.web.servlet.view.document.AbstractPdfView.renderMergedOutputModel(AbstractPdfView.java:82)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1243)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)
at com.test.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:66)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.jrHandle(ServletInitialHandler.java)
at org.zeroturnaround.javarebel.integration.servlet.undertow.cbp.ServletInitialHandlerCBP.handleRequest(ServletInitialHandlerCBP.java:101)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
코드 :
document.open();
PDFGenerator.createSummaryTable(document, table, dataList, relPath);
document.close();
pdfWriter.close();
os.flush();
os.close();
byte b[] = os.toByteArray();
ByteArrayOutputStream os1 = new ByteArrayOutputStream();
PdfReader pdfReader = new PdfReader(b);
PdfStamper pdfStamper = new PdfStamper(pdfReader, os1);
pdfStamper.setViewerPreferences(PdfWriter.PDFXNONE);
pdfStamper.setViewerPreferences(PdfWriter.HideMenubar);
pdfStamper.setViewerPreferences(PdfWriter.HideToolbar);
pdfStamper.setViewerPreferences(PdfWriter.HideWindowUI);
PdfWriter pdfWriter1 = pdfStamper.getWriter();
pdfWriter1.addJavaScript(getPrintJS());
pdfReader.close();
pdfStamper.close();
os1.flush();
os1.close();
OutputStream os2 = httpServletResponse.getOutputStream();
os2.write(os1.toByteArray());
os2.flush();
os2.close();
'createSummaryTable()'메소드에서 수행중인 작업을 아무도 볼 수 없습니다. 이 PDF를 두 번 통과시켜야한다는 것은 매우 이상한 일입니다. 뷰어 설정을하고'createSummaryTable()'메소드에서 JavaScript를 추가하는 것은 매우 쉽습니다. 어쨌든, 당신은 이미 닫힌'ServletOutputStream'에 무언가를 쓰려고합니다. 그것은 iText 문제가 아닙니다. 그건 초등 서블릿 문제입니다. –
명시 적으로 'ServletOutputStream'을 명시 적으로 닫지 않은 경우에도 서버에 의해 닫힐 수 있습니다. 타임 아웃으로 인해 또한 직접적으로'HttpServletResponse.getOutputStream()'에 쓰는 것이 프레임 워크의 틀린 패턴입니다 : 프레임 워크는 결국 응답을 시도하고 쓰는 것처럼 보입니다. 따라서 프레임 워크, 특히 Spring 웹 프레임 워크의 사용을 확인하십시오. – mkl
스택 트레이스의 "by by by"라인은 어디에 있습니까? – kolossus