title: TimeoutException on remote Glassfish v4.1 deployment
body: <p>I have VPS on OVH, lets say it's vpsXXXX.ovh.net, with Debian 7. I've installed Java 8, Glassfish 4.1 and enabled secure admin:</p>
  
  <pre><code>asadmin
  &gt; change-admin-password --user admin
  &gt; start-domain
  &gt; enable-secure-admin # user: admin
  &gt; restart-domain
  </code></pre>
  
  <p>I've checked that vpsXXXX.ovh.net:8080 and vpsXXXX.ovh.net:4848 works. When I've uploaded my war by scp, logged on VPS by SSH and deployed by <code>asadmin deploy JEE.war</code> everything worked.</p>
  
  <p>Then I've undeployed it and tried to deploy it from remotely by command:</p>
  
  <pre><code>asadmin --user admin --host vpsXXXX.ovh.net --port 4848 --secure deploy JEE.war
  </code></pre>
  
  <p>I gave admin password and after a long time (30 sec?) i got:</p>
  
  <pre><code>remote failure: Request failed.
  Command deploy failed.
  </code></pre>
  
  <p>My server.log on VPS:</p>
  
  <pre><code>[2014-11-03T21:50:14.489+0100] [glassfish 4.1] [INFO] [NCLS-REST-00003] [javax.enterprise.admin.rest] [tid: _ThreadID=46 _ThreadName=admin-listener(5)] [timeMillis: 1415047814489] [levelValue: 800] [[
    An error occurred while processing the request. Please see the server logs for details.
  org.jvnet.mimepull.MIMEParsingException: java.io.IOException: java.util.concurrent.TimeoutException
          at org.jvnet.mimepull.MIMEParser.fillBuf(MIMEParser.java:442)
          at org.jvnet.mimepull.MIMEParser.skipPreamble(MIMEParser.java:307)
          at org.jvnet.mimepull.MIMEParser.access$300(MIMEParser.java:68)
          at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:149)
          at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:132)
          at org.jvnet.mimepull.MIMEMessage.makeProgress(MIMEMessage.java:198)
          at org.jvnet.mimepull.MIMEMessage.parseAll(MIMEMessage.java:181)
          at org.jvnet.mimepull.MIMEMessage.getAttachments(MIMEMessage.java:106)
          at com.sun.enterprise.admin.remote.reader.MultipartProprietaryReader.readFrom(MultipartProprietaryReader.java:98)
          at org.glassfish.admin.rest.readers.MultipartFDPayloadReader.readFrom(MultipartFDPayloadReader.java:72)
          at org.glassfish.admin.rest.readers.MultipartFDPayloadReader.readFrom(MultipartFDPayloadReader.java:59)
          at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:251)
          at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:229)
          at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:149)
          at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:73)
          at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:149)
          at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1124)
          at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:851)
          at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:270)
          at org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider$EntityValueFactory.provide(EntityParamValueFactoryProvider.java:96)
          at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81)
          at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:121)
          at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
          at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
          at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387)
          at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331)
          at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103)
          at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:271)
          at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
          at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
          at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
          at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
          at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
          at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
          at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
          at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028)
          at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:365)
          at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173)
          at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
          at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
          at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
          at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
          at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
          at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
          at java.lang.Thread.run(Thread.java:745)
  Caused by: java.io.IOException: java.util.concurrent.TimeoutException
          at org.glassfish.grizzly.nio.transport.TCPNIOTransportFilter.handleRead(TCPNIOTransportFilter.java:90)
          at org.glassfish.grizzly.filterchain.TransportFilter.handleRead(TransportFilter.java:173)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.read(DefaultFilterChain.java:351)
          at org.glassfish.grizzly.filterchain.FilterChainContext.read(FilterChainContext.java:695)
          at org.glassfish.grizzly.portunif.BackChannelFilter.handleRead(BackChannelFilter.java:80)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.read(DefaultFilterChain.java:351)
          at org.glassfish.grizzly.filterchain.FilterChainContext.read(FilterChainContext.java:695)
          at org.glassfish.grizzly.portunif.BackChannelFilter.handleRead(BackChannelFilter.java:80)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.read(DefaultFilterChain.java:351)
          at org.glassfish.grizzly.filterchain.FilterChainContext.read(FilterChainContext.java:695)
          at org.glassfish.grizzly.http.io.InputBuffer.blockingRead(InputBuffer.java:1119)
          at org.glassfish.grizzly.http.server.io.ServerInputBuffer.blockingRead(ServerInputBuffer.java:95)
          at org.glassfish.grizzly.http.io.InputBuffer.fill(InputBuffer.java:1143)
          at org.glassfish.grizzly.http.io.InputBuffer.read(InputBuffer.java:353)
          at org.glassfish.grizzly.http.server.NIOInputStreamImpl.read(NIOInputStreamImpl.java:83)
          at org.glassfish.jersey.message.internal.EntityInputStream.read(EntityInputStream.java:101)
          at org.jvnet.mimepull.MIMEParser.fillBuf(MIMEParser.java:440)
          ... 71 more
  Caused by: java.util.concurrent.TimeoutException
          at org.glassfish.grizzly.nio.tmpselectors.TemporarySelectorReader.read(TemporarySelectorReader.java:126)
          at org.glassfish.grizzly.nio.tmpselectors.TemporarySelectorReader.read(TemporarySelectorReader.java:75)
          at org.glassfish.grizzly.AbstractReader.read(AbstractReader.java:72)
          at org.glassfish.grizzly.nio.transport.TCPNIOTransportFilter.handleRead(TCPNIOTransportFilter.java:77)
          ... 96 more
  ]]
  
  [2014-11-03T21:50:14.505+0100] [glassfish 4.1] [WARNING] [NCLS-CORE-00090] [javax.enterprise.system.core] [tid: _ThreadID=46 _ThreadName=admin-listener(5)] [timeMillis: 1415047814505] [levelValue: 900] [[
    Internal Server error: /command/deploy
  java.lang.RuntimeException: java.lang.IllegalStateException: Illegal attempt to call getOutputStream() after getWriter() has already been called.
          at org.glassfish.admin.rest.adapter.RestAdapter.reportError(RestAdapter.java:346)
          at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:209)
          at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
          at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
          at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
          at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
          at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
          at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.IllegalStateException: Illegal attempt to call getOutputStream() after getWriter() has already been called.
          at org.glassfish.grizzly.http.server.Response.getNIOOutputStream(Response.java:624)
          at org.glassfish.grizzly.http.server.Response.getOutputStream(Response.java:649)
          at org.glassfish.admin.rest.adapter.RestAdapter.reportError(RestAdapter.java:342)
          ... 34 more
  ]]
  
  [2014-11-03T21:50:14.515+0100] [glassfish 4.1] [WARNING] [NCLS-CORE-00091] [javax.enterprise.system.core] [tid: _ThreadID=46 _ThreadName=admin-listener(5)] [timeMillis: 1415047814515] [levelValue: 900] [[
    Unable to set customized error page
  java.lang.IllegalStateException: Illegal attempt to call sendError() after the response has been committed.
          at org.glassfish.grizzly.http.server.Response.sendError(Response.java:1327)
          at org.glassfish.grizzly.http.server.Response.sendError(Response.java:1309)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
          at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
          at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
          at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
          at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
          at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
          at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
          at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
          at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
          at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
          at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
          at java.lang.Thread.run(Thread.java:745)
  ]]
  </code></pre>
  
  <p>Alternatively, this commands runs without problems:
  list domains from remote:</p>
  
  <pre><code>asadmin --user admin --host vpsXXXX.ovh.net --port 4848 --secure list-domains
  domain1 running
  Command list-domains executed successfully.
  </code></pre>
  
  <p>deploy on localhost:</p>
  
  <pre><code>asadmin --user admin --host localhost --port 4848 deploy --force JEE.war
  </code></pre>