HttpServletResponseImpl

HttpServletResponseImpl

本文介绍了上传大文件错误到wildfly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图上传大文件(400MB +)wildfly 8.1,我得到了一个IOException,但我没有遇到任何异常与相同的条件,当使用JBoss 7服务器:



例外:
$ b $ pre $ 阻塞请求失败HttpServerExchange {POST / ehub / contentstore / categories / maincategory / file / create}:java.lang .RuntimeException:java.io.IOException:在io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:527)
处发生故障
在io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest (ServletInitialHandler.java:287)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
at io.undertow.servlet.handlers.ServletInitialHandler.access $ 000(ServletInitialHandler。 java:73)
at io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(ServletInitialHandler.java:146)
at io.undertow.server.Connectors.executeRootHandler(如果您使用的是Java虚拟机,则可以使用以下命令:
at io.undertow.server.HttpServerExchange $ 1.run(HttpServerExchange.java:727)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[ rt.jar:1.7.0_51]
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)[rt.jar:1.7.0_51]
在java.lang.Thread .run(Thread.java:744)[rt.jar:1.7.0_51]
导致:java.io.IOException:在sun.nio.ch.FileDispatcherImpl.write0中损坏的管道
(Native Method )[rt.jar:1.7.0_51]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)[rt.jar:1.7.0_51]
at sun.nio.ch .IOUtil.writeFromNativeBuffer(IOUtil.java:93)[rt.jar:1.7.0_51]
at sun.nio.ch.IOUtil.write(IOUtil.java:51)[rt.jar:1.7.0_51]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)[rt.jar:1.7.0_51]
at org.xnio.nio.NioSocketConduit.write(NioSocketConduit.java:150 )[xnio-nio-3.2.2.Final.jar:3.2.2.Final]
at io.underto w.server.protocol.http.HttpResponseConduit.processWrite(HttpResponseConduit.java:212)
at io.undertow.server.protocol.http.HttpResponseConduit.flush(HttpResponseConduit.java:629)
at io。 (FinishableStreamSinkConduit.java:83)
at org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)[xnio-api-3.2.2.Final.jar:3.2。 2.Final]
at io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
at org.xnio.channels.Channels.flushBlocking(Channels.java:63)[xnio-api -3.2.2.Final.jar:3.2.2.Final]
at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
at io.undertow.servlet.spec .httpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)



standalone.xml:

 < subsystem xmlns =urn:jboss:domain:undertow:1.1> 
< buffer-cache name =default/>
< server name =default-server>
< http-listener name =defaultsocket-binding =httpmax-post-size =974247881/>
< host name =default-hostalias =localhost>
< location name =/handler =welcome-content/>
< filter-ref name =server-header/>
< filter-ref name =x-powered-by-header/>
< / host>
< / server>
< servlet-container name =default>
< jsp-config />
< / servlet-container>
< handlers>
< / handlers>
< filters>
< response-header name =server-headerheader-name =Serverheader-value =WildFly / 8/>
< response-header name =x-powered-by-headerheader-name =X-Powered-Byheader-value =Undertow / 1/>
< / filters>
< / subsystem>


解决方案

我有同样的问题,我解决了这个问题。它可以帮助其他人。



为了允许更多的http请求头大小,您需要更改jboss或wildfly的standalone.conf文件。

将max-header-size属性添加到默认服务器,并重新启动服务器,它将工作
Standalone.conf

 < subsystem xmlns =urn:jboss:domain:undertow:1.1> 
< buffer-cache name =default/>
< server name =default-server>
< http-listener name =defaultsocket-binding =httpmax-header-size =974247881/>
< host name =default-hostalias =localhost>
< location name =/handler =welcome-content/>
< filter-ref name =server-header/>
< filter-ref name =x-powered-by-header/>
< / host>
< / server>
...
< / subsystem>


I try to upload large files(400mb+) to wildfly 8.1 and i get an IOException but i dont encounter any exception with the same conditions when using jboss 7 server:

Exception:

Blocking request failed HttpServerExchange{ POST /ehub/contentstore/categories/maincategory/file/create}: java.lang.RuntimeException: java.io.IOException: Broken pipe
    at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:527)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method) [rt.jar:1.7.0_51]
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) [rt.jar:1.7.0_51]
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) [rt.jar:1.7.0_51]
    at sun.nio.ch.IOUtil.write(IOUtil.java:51) [rt.jar:1.7.0_51]
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487) [rt.jar:1.7.0_51]
    at org.xnio.nio.NioSocketConduit.write(NioSocketConduit.java:150) [xnio-nio-3.2.2.Final.jar:3.2.2.Final]
    at io.undertow.server.protocol.http.HttpResponseConduit.processWrite(HttpResponseConduit.java:212)
    at io.undertow.server.protocol.http.HttpResponseConduit.flush(HttpResponseConduit.java:629)
    at io.undertow.conduits.FinishableStreamSinkConduit.flush(FinishableStreamSinkConduit.java:83)
    at org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
    at org.xnio.channels.Channels.flushBlocking(Channels.java:63) [xnio-api-3.2.2.Final.jar:3.2.2.Final]
    at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:625)
    at io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
    at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)

I increased the max-post-size but it didnt work.

standalone.xml :

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
        <buffer-cache name="default"/>
        <server name="default-server">
            <http-listener name="default" socket-binding="http" max-post-size="974247881"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>
        <servlet-container name="default">
            <jsp-config/>
        </servlet-container>
        <handlers>
            <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
        </handlers>
        <filters>
            <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
            <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
        </filters>
</subsystem>
解决方案

I have found solution for this. I had this same issue and I solved it. It may help others.

For allowing more http request header size you need to change standalone.conf file of jboss or wildfly.

Add max-header-size attribute to default server and restart the server it will workStandalone.conf

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
        <buffer-cache name="default"/>
        <server name="default-server">
            <http-listener name="default" socket-binding="http" max-header-size="974247881"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>
...
</subsystem>

这篇关于上传大文件错误到wildfly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:37