0
게시물 요청을 보내기 위해 RestTemplate
을 사용하고 있습니다. 이런 식으로 뭔가 :java.net.SocketException : RestTemplate이 잘못된 인수
restTemplate.postForObject(url, fetchImageDataRequest, SimpleImageHolder[].class);
나는 그런 restTemplate
을 만들 때 :
restTemplate = new RestTemplate();
MappingJacksonHttpMessageConverter converter = new MappingJacksonHttpMessageConverter();
restTemplate.getMessageConverters().add(converter);
모든 것이 잘 작동합니다. 나는이 같은 spring.xml에서 생성 정의 RestTemplate
사용할 때 :
<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">
<constructor-arg>
<bean class="org.apache.commons.httpclient.params.HttpClientParams" />
</constructor-arg>
<property name="httpConnectionManager" ref="reHttpConnectionManager" />
<property name="state">
<bean class="org.apache.commons.httpclient.HttpState" />
</property>
</bean>
</constructor-arg>
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg ref="reRequestFactory" />
</bean>
을 나는 java.net.SocketException: Invalid argument
예외를 얻을. 이 문제를 파악하려고합니다.
전체의 stacke 추적 :
org.springframework.web.client.ResourceAccessException: I/O error: Invalid argument; nested exception is java.net.SocketException: Invalid argument
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:453)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:279)
전체 스택 추적을 게시하십시오. –
@SotiriosDelimanolis - 추가되었습니다. 감사! – Avi