i trying connect smartsheet api using java program. had problems site certificate resolved adding java keystore. when trying run code, following error.
exception in thread "main" java.lang.nosuchfielderror: instance @ org.apache.http.conn.ssl.sslconnectionsocketfactory.<clinit>(sslconnectionsocketfactory.java:144) @ org.apache.http.impl.client.httpclientbuilder.build(httpclientbuilder.java:955) @ org.apache.http.impl.client.httpclients.createdefault(httpclients.java:58) @ com.smartsheet.api.internal.http.defaulthttpclient.<init>(defaulthttpclient.java:64) @ com.smartsheet.api.smartsheetbuilder.build(smartsheetbuilder.java:203) @ smartsheetconnection.main(smartsheetconnection.java:13)
this code (i followed documentation).
import com.smartsheet.api.*; import com.smartsheet.api.models.*; import com.smartsheet.api.models.enums.*; import com.smartsheet.api.oauth.*; public class smartsheetconnection { public static void main(string[] args) throws smartsheetexception { // set access token. token token = new token(); token.setaccesstoken("foo"); smartsheet smartsheet = new smartsheetbuilder().setaccesstoken(token.getaccesstoken()).build(); } }
the line throwing error (line 144)
@deprecated public static final x509hostnameverifier allow_all_hostname_verifier = allowallhostnameverifier.instance;
but not sure make of it. using maven dependencies. have version of apache httpcomponents?
here pom.xml
<build> <sourcedirectory>src</sourcedirectory> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <artifactid>maven-war-plugin</artifactid> <version>2.4</version> <configuration> <warsourcedirectory>webcontent</warsourcedirectory> <failonmissingwebxml>false</failonmissingwebxml> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>com.smartsheet</groupid> <artifactid>smartsheet-sdk-java</artifactid> <version>2.0.2</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.sun.jersey.contribs</groupid> <artifactid>jersey-apache-client</artifactid> <version>1.9</version> </dependency> </dependencies>
other posts error seem suggest it's typically caused conflicting versions of httpcore
jar. i.e., older version of httpcore
on classpath.
for more information, i'd suggest checkout following posts:
Comments
Post a Comment