<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=mpilone" rel="nofollow">Michael Pilone</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8013?redirect=false" rel="nofollow">SPR-8013</a></strong> and commented</p>
<p dir="auto">I've been debugging an issue while using the Jetty ProxyServlet to proxy all requests to a backend server which uses the mvc:resources namespace element. I finally tracked the issue down to Jetty's ProxyServlet hanging while waiting for content from the backend server. Originally I thought this was a Jetty issue, but as I look at the HTTP headers, I think it is an issue with ResourceHttpRequestHandler.</p>
<p dir="auto">ResourceHttpRequestHandler, at line 124 always sets the HTTP headers of Content-Length and Content-Type. Immediately after this call, at line 125, the response is returned if it is found that the resource hasn't changed and a 304 can be returned. What this means is that a "304 Not Modified" status is returned but the Content-Length header is also set.</p>
<p dir="auto">I've found conflicting reports as to who is in the wrong here, but RFC 2616 section 10.3.5 says,</p>
<p dir="auto">"If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers."</p>
<p dir="auto">of course, RFC 2616 section 4.4 says,</p>
<p dir="auto">"Any response message which "MUST NOT" include a message-body (such as the 1xx, 204, and 304 responses and any response to a HEAD request) is always terminated by the first empty line after the header fields, regardless of the entity-header fields present in the message."</p>
<p dir="auto">So, in either case (strong or weak validators), it seems like the ResourceHttpRequestHandler should not be setting a Content-Length header because clients could hang waiting for the content. However, clients should be smart enough to ignore content-length header on a 304. This is probably something that should be fixed on both sides!</p>
<p dir="auto">The forum thread contains a simple workaround where the content length is reset to 0 if a 304 status is set.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5</p>
<p dir="auto"><strong>Reference URL:</strong> <a href="http://forum.springsource.org/showthread.php?t=104505" rel="nofollow">http://forum.springsource.org/showthread.php?t=104505</a></p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398108452" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12362" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12362/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12362">#12362</a> 304 responses should not have non-0 Content-Length (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=jansiemerlin@gmail.com" rel="nofollow">Jansie Merlin</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4118?redirect=false" rel="nofollow">SPR-4118</a></strong> and commented</p>
<p dir="auto">My Issue is same as the one explained in the below link.</p>
<p dir="auto"><a href="http://opensource.atlassian.com/projects/spring/browse/SPR-4077" rel="nofollow">http://opensource.atlassian.com/projects/spring/browse/SPR-4077</a></p>
<p dir="auto">But my use gets resolved after adding the below param to the Spring Config file</p>
<p dir="auto">&lt;property name="useTransactionAwareDataSource" value="true"/&gt;</p>
<p dir="auto">&lt;prop key="hibernate.connection.release_mode"&gt;after_statement&lt;/prop&gt;</p>
<p dir="auto">and<br>
&lt;property name="transactionSynchronization"&gt;<br>
&lt;bean id="org.springframework.transaction.jta.JtaTransactionManager.SYNCHRONIZATION_NEVER"<br>
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/&gt;<br>
&lt;/property&gt;<br>
to transactionManager bean.</p>
<p dir="auto">If  SYNCHRONIZATION_NEVER is used the below exception is thrown which getCurrentSession is invoked.<br>
INFO  [HibernateUtil] getCurrentSession in data DS..<br>
2007-11-17 03:05:08,231 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'LoadDataSessionFactory'<br>
2007-11-17 03:05:08,231 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Opening Hibernate Session<br>
2007-11-17 03:05:08,231 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11952867082<br>
2007-11-17 03:05:08,231 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Closing Hibernate Session<br>
2007-11-17 03:05:08,231 ERROR [HibernateUtil] Error in getCurrentSession:<br>
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here<br>
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean$TransactionAwareInvocationHandler.invoke(AbstractSessionFactoryBean.java:296)<br>
at $Proxy61.getCurrentSession(Unknown Source)<br>
at HibernateUtil.getCurrentSession(LoadDataHibernateUtil.java:74)<br>
.................</p>
<p dir="auto">Please Helpout......<br>
Thanks in Advance for Springs Support</p>
<p dir="auto">Is this the only solution for this issue? Or do we have any fix versions that spring is going to release?.</p>
<p dir="auto">We are using Spring.jar 2.0.2</p>
<hr>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398082426" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8755" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8755/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8755">#8755</a> PROPAGATION_REQUIRES_NEW fails on JBoss 4.2.1 when using Hibernate connection release mode "on_close" (<em><strong>"duplicates"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398082760" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8801" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8801/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8801">#8801</a> Propagation REQUIRES_NEW fails on JBoss Application Server 4.2.1 when keeping a JDBC Connection handle</li>
</ul>