[jcifs] NTLM - getOutputStream() has already been called for this response

Bill Comer bill.comer at gmail.com
Wed Feb 11 17:11:57 GMT 2009


Using spring-security 2.0.4 and spring 2.5.5, with jcifs 1.2.25

Trying to download a file gets the stacktraces shown below.
I have found this jcifs post dating wayback to 2004
http://markmail.org/message/xrpgja4jvcglhguh#query:related%3Axrpgja4jvcglhguh+page:1+mid:xrpgja4jvcglhguh+state:results
but the proposed solution does not appear to have been implemented.

I believe the problem is related to the IE Post problem I raised
recently but the fix for that described
http://billcomer.blogspot.com/2009/01/ntlm-authentication-and-ie-post-problem.html
does not fix this issue.

On the screen the follwoing stacktrace is shown:
   org.apache.jasper.JasperException: java.lang.IllegalStateException:
getOutputStream() has already been called for this response
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:240)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:258
  org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1174)

Furhter up the console there is:

11-02-2009 16:34:39 [http-7070-3] DEBUG - New SecurityContext instance
will be associated with SecurityContextHolder
11-02-2009 16:34:39 [http-7070-3] DEBUG - /printFiles/temp31735.rtf at
position 2 of 4 in additional filter chain; firing Filter:
'org.springframework.security.ui.ExceptionTranslationFilter[
order=1400; ]'
11-02-2009 16:34:39 [http-7070-3] DEBUG - /printFiles/temp31735.rtf at
position 3 of 4 in additional filter chain; firing Filter:
'org.springframework.security.ui.ntlm.NtlmProcessingFilter[
order=1500; ]'
11-02-2009 16:34:39 [http-7070-3] DEBUG - Starting NTLM handshake
11-02-2009 16:34:39 [http-7070-3] DEBUG - Authentication exception
occurred; redirecting to authentication entry point
org.springframework.security.ui.ntlm.NtlmBeginHandshakeException: NTLM
	at org.springframework.security.ui.ntlm.NtlmProcessingFilter.doFilterHttp(NtlmProcessingFilter.java:317)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)
11-02-2009 16:34:39 [http-7070-3] DEBUG - Authentication entry point
being called; SavedRequest added to Session:
SavedRequest[http://localhost:7070/dfweb/printFiles/temp31735.rtf]
11-02-2009 16:34:39 [http-7070-3] DEBUG - SecurityContextHolder now
cleared, as request processing completed
11-02-2009 16:34:39 [http-7070-2] DEBUG - Trying to find handler for
exception of type [java.io.IOException]
11-02-2009 16:34:39 [http-7070-2] DEBUG - Found handler for exception
of type [java.lang.Throwable]: public void
uk.co.formfill.springutils.aspects.logging.Log4JThrowsAdvice.afterThrowing(java.lang.reflect.Method,java.lang.Object[],java.lang.Object,java.lang.Throwable)
11-02-2009 16:34:39 [http-7070-2] ERROR - PrintController.handleRequest - ERROR
java.io.IOException: Authentication failure
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.URL.openStream(Unknown Source)
	at uk.co.formfill.dfweb.controller.PrintController.onSubmit(PrintController.java:109)
	at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)

The call in the controller causing all the problems is  url.openStream():
  protected ModelAndView onSubmit(HttpServletRequest request,
                                  HttpServletResponse response,
                                  Object command,
                                  BindException errors)
    throws Exception
    {
      File file = getFile();
      String fileURL = "http://" + request.getServerName() + ":"
          + request.getServerPort() + request.getContextPath() + "/"
          + findPrintDir(file) + "/" + file.getName();
      URL url = new URL(fileURL);
      url.openStream();
      ......
   }

Ant thoughts please?


More information about the jcifs mailing list