I couldn't find what the problem was but I just removed the HttpParams
bean from the constructor of the bean httpClient
and removed completely the HttpState
and now it works. The new XML looks like this:
<bean id="reHttpConnectionManager" class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
<property name="params">
<bean class="org.apache.commons.httpclient.params.HttpConnectionManagerParams">
<property name="soTimeout" value="30000"/>
<property name="connectionTimeout" value="30000"/>
<property name="maxTotalConnections" value="300"/>
<property name="defaultMaxConnectionsPerHost" value="50"/>
</bean>
</property>
</bean>
<bean id="reRequestFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory">
<property name="readTimeout" value="3000" />
<constructor-arg>
<bean id="httpClient" class="org.apache.commons.httpclient.HttpClient">
<property name="httpConnectionManager" ref="reHttpConnectionManager" />
</bean>
</constructor-arg>
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg ref="reRequestFactory" />
</bean>