1 Reply Latest reply on Jan 25, 2012 2:49 PM by Bruno Santos

    RESTEasy error on video download!

    Bruno Santos Newbie

      Hi,

       

      I'm using JBoss 7.0.2.Final and I'm having a strange issue in order to successfully provide a mp4 video to an HTML5 tag. Everytime the tag access the url it fails with the following execption:

       

       

      17:35:25,171 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] (http--0.0.0.0-8080-5) Failed executing GET /download/video/baa/foo/sintel.mp4: org.jboss.resteasy.spi.WriterException: ClientAbortException:  java.net.SocketException: Software caused connection abort: socket write error

                at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:262) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.1.GA.jar:]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at java.lang.Thread.run(Unknown Source) [:1.6.0_29]

      Caused by: ClientAbortException:  java.net.SocketException: Software caused connection abort: socket write error

                at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:403) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:449) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:293) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.connector.OutputBuffer.writeByte(OutputBuffer.java:444) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:77) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.jboss.resteasy.util.CommitHeaderOutputStream.write(CommitHeaderOutputStream.java:38) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.providers.InputStreamProvider.writeTo(InputStreamProvider.java:60) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.providers.InputStreamProvider.writeTo(InputStreamProvider.java:22) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:63) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250) [resteasy-jaxrs-2.2.1.GA.jar:]

                ... 22 more

      Caused by: java.net.SocketException: Software caused connection abort: socket write error

                at java.net.SocketOutputStream.socketWrite0(Native Method) [:1.6.0_29]

                at java.net.SocketOutputStream.socketWrite(Unknown Source) [:1.6.0_29]

                at java.net.SocketOutputStream.write(Unknown Source) [:1.6.0_29]

                at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:726) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:449) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:750) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:126) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:559) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.Response.doWrite(Response.java:594) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:398) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                ... 33 more

       

       

      17:35:25,174 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/webapp].[com.foo.rest.RestServiceLocator]] (http--0.0.0.0-8080-5) Servlet.service() for servlet com.foo.rest.RestServiceLocator threw exception: java.lang.IllegalStateException

                at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:408) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:71) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.handleFailure(SynchronousDispatcher.java:262) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.handleWriterException(SynchronousDispatcher.java:379) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:218) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.handleWriteResponseException(SynchronousDispatcher.java:203) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:504) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.1.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.1.GA.jar:]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

                at java.lang.Thread.run(Unknown Source) [:1.6.0_29]

       

       

      HTML5 tag:

       

      <video controls="controls">    

           <source src="rest/download/video/baa/foo/sintel.mp4" type="video/mp4">    

           Your browser does not support the video tag.    

      </video>

       

       

      RESTEasy:

       

      @GET

      @Path("/video/{path:.*}")

      @Produces("video/mp4")

      @Override

      public InputStream downloadVideo(@PathParam("path") String path) {

           log.info("REST: (windowing layouts) /webapp/rest/download/video/" + path);


           String archiveDir = (String) System.getProperties().get("archive.url");

           if (archiveDir == null) throw new WebApplicationException(Response.Status.SERVICE_UNAVAILABLE);
           File file = new File(archiveDir + File.separator + path);

           if (!file.exists() || !file.isFile() || file.isHidden()) throw new WebApplicationException(Response.Status.BAD_REQUEST);

           InputStream is = null;

           try {

                is = new FileInputStream(file);

           } catch (Exception e) {

       

       

       

       

       

                throw new WebApplicationException(Response.Status.NO_CONTENT);

           }

       

           return is;

       

          

           // I've also tried returning the file through the Response.ok() method and it fails with same error:

             // ResponseBuilder rb = Response.ok(file);

             // rb.header("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"");

             // return rb.build();

      }

       

      Any idea why this is failing?

       

      Thanks