maven - HttpClientBuilder - java.lang.NoSuchFieldError: INSTANCE -
i have maven java project uses httpclient execute http requests. on local java web server works fine. after deploy sap hana cloud platform following error:
java.lang.nosuchfielderror: instance @ org.apache.http.impl.io.defaulthttprequestwriterfactory.<init>(defaulthttprequestwriterfactory.java:52) @ org.apache.http.impl.io.defaulthttprequestwriterfactory.<init>(defaulthttprequestwriterfactory.java:56) @ org.apache.http.impl.io.defaulthttprequestwriterfactory.<clinit>(defaulthttprequestwriterfactory.java:46) @ org.apache.http.impl.conn.managedhttpclientconnectionfactory.<init>(managedhttpclientconnectionfactory.java:72) @ org.apache.http.impl.conn.managedhttpclientconnectionfactory.<init>(managedhttpclientconnectionfactory.java:84) @ org.apache.http.impl.conn.managedhttpclientconnectionfactory.<clinit>(managedhttpclientconnectionfactory.java:59) @ org.apache.http.impl.conn.poolinghttpclientconnectionmanager$internalconnectionfactory.<init>(poolinghttpclientconnectionmanager.java:493) @ org.apache.http.impl.conn.poolinghttpclientconnectionmanager.<init>(poolinghttpclientconnectionmanager.java:149) @ org.apache.http.impl.conn.poolinghttpclientconnectionmanager.<init>(poolinghttpclientconnectionmanager.java:138) @ org.apache.http.impl.conn.poolinghttpclientconnectionmanager.<init>(poolinghttpclientconnectionmanager.java:114) @ org.apache.http.impl.client.httpclientbuilder.build(httpclientbuilder.java:726) @ com.sap.hana.cloud.odata.service.olingosampleapp.gethttpclient(olingosampleapp.java:382) @ com.sap.hana.cloud.odata.service.olingosampleapp.getcsrftoken(olingosampleapp.java:374) @ com.sap.hana.cloud.odata.service.odatacalls.doget(odatacalls.java:163) ...
my dependency looks this:
<dependency> <groupid>org.apache.httpcomponents</groupid> <artifactid>httpclient</artifactid> <version>4.3.5</version> <scope>compile</scope> </dependency>
according question java.lang.nosuchfielderror: org.apache.http.message.basiclineformatter.instance mashape unirest in java application tried use following code classloader ressource.
classloader classloader = this.getclass().getclassloader(); url resource = classloader.getresource("org/apache/http/impl/client/httpclientbuilder.class"); return resource;
and returns following
"jar:file:/some/path/web-inf/lib/httpclient-4.3.5.jar!/org/apache/http/impl/client/httpclientbuilder.class"
you can see jar-versions same. every similar question looked @ had incoherent jar-versions source of failure. there reason error?
update
after discussion in comments i'll update question:
dependency tree:
so see version conflict , removed neo-java-web-api
. classloader returns version 4.3.2 again. still error beginning.
the new, complete dependency tree without neo-java-web-api
looks following:
i still couldn't find solution actual problem. @ least find workaround. changed scope <scope>provided</scope>
, use functions, available in version 4.1.4. example new defaulthttpclient(cm);
instead of httpclientbuilder.create().build();
Comments
Post a Comment