简体   繁体   中英

java.lang.NoSuchMethodError: org/apache/http/conn/scheme/Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V

I'm trying to Set the ConnectionTimeout and ReadTimeout in the Spring WebServiceTemplate by using the HttpComponentsMessageSender. However, I'm getting NoSuchMethodError for the SchemeSocketFactory class.

<bean
    class="org.springframework.ws.transport.http.HttpComponentsMessageSender"
    id="timeoutId">
    <property name="connectionTimeout" value="3000" />
    <property name="readTimeout" value="3000" />
</bean>

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.transport.http.HttpComponentsMessageSender]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org/apache/http/conn/scheme/Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147)
    ... 65 more
Caused by: java.lang.NoSuchMethodError: org/apache/http/conn/scheme/Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
    at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:51)
    at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:96)
    at org.springframework.ws.transport.http.HttpComponentsMessageSender.<init>(HttpComponentsMessageSender.java:77)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
    ... 67 more

I think a fixpack upgrade will fix this for you. WebSphere has an internal copy of the Apache HTTP client (used by its JAX-RS implementation) that was visible to installed applications until fixpack 8.5.5.9. If you want to use your own copy on a fixpack prior to that, you'll need to utilize PARENT_LAST class loader delegation or an isolated shared library in order to make sure that the class loader loads your own copy of Apache HTTP instead of WebSphere's.

A NoSuchMethodError indicates that classes available at runtime are different to those used to compile your code.

It usually boils down to having multiple versions of the same class on the classpath. Double check this for the class in question and remove the unwanted version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM