jfrog / artifactory-client-java

Artifactory REST Client Java API bindings
Apache License 2.0
319 stars 153 forks source link

Using in Android causes a "No static field" #362

Open hannesa2 opened 1 year ago

hannesa2 commented 1 year ago

In an Android Gradle project using implementation 'org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0' I run with

        val artifactory: Artifactory = ArtifactoryClientBuilder.create()
            .setUrl("https://artifactory.server.info")
            .build()

into this

    java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes4.dex)
        at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
        at org.jfrog.artifactory.client.httpClient.http.HttpBuilderBase.createConnectionMgr(HttpBuilderBase.java:359)
        at org.jfrog.artifactory.client.httpClient.http.HttpBuilderBase.configConnectionManager(HttpBuilderBase.java:344)
        at org.jfrog.artifactory.client.httpClient.http.HttpBuilderBase.build(HttpBuilderBase.java:78)
        at org.jfrog.artifactory.client.ArtifactoryClientBuilder.createClientBuilder(ArtifactoryClientBuilder.java:174)
        at org.jfrog.artifactory.client.ArtifactoryClientBuilder.build(ArtifactoryClientBuilder.java:196)
        at info.hannes.appUpdate.AppUpdateHelper.requestArtifactoryVersions(AppUpdateHelper.kt:159)

Does someone has an idea how to get rid of it ?

hannesa2 commented 1 year ago

Running the sample from https://github.com/jfrog/project-examples/tree/master/artifactory-client-java-examples/gradle-example I run into this issue https://github.com/jfrog/artifactory-client-java/issues/203

Exception in thread "main" org.apache.http.client.HttpResponseException: status code: 400, reason phrase: {
  "errors" : [ {
    "status" : 400,
    "message" : "This REST API is available only in Artifactory Pro (see: jfrog.com/artifactory/features). If you are already running Artifactory Pro please make sure your server is activated with a valid license key.\n"
  } ]
}
    at org.jfrog.artifactory.client.impl.ArtifactoryImpl.newHttpResponseException(ArtifactoryImpl.java:229)
    at org.jfrog.artifactory.client.impl.ArtifactoryImpl.put(ArtifactoryImpl.java:336)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrap.invoke(PojoMetaMethodSite.java:213)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.jfrog.artifactory.client.impl.RepositoriesImpl.create(RepositoriesImpl.groovy:37)
    at org.jfrog.example.ClientExample.createNewRepository(ClientExample.java:103)
    at org.jfrog.example.ClientExample.main(ClientExample.java:49)

That's why this is obsolete now

yahavi commented 1 year ago

@hannesa2, Thanks for reporting this issue! For some reason, the AllowAllHostnameVerifier class is missing from the Apache HTTP client in your classpath. However, we couldn't reproduce this issue. I believe that upgrading the httpclient to 5 may possibly resolve this issue - https://github.com/jfrog/artifactory-client-java/blob/2.13.0/build.gradle#L62

Would you like to contribute code to the Artifactory Java client project? Alternatively, could you please provide a minimal reproducer?

We are looking forward to your response.

hannesa2 commented 1 year ago

Sure, I can provide a pull request which point this out. In the meantime I run into this

automationhoda1 commented 1 year ago

Hi,

About the Firefox the Signup with Google spins, can you please write in which environment do you work(Is it windows/ mac (which macOS name?) and which Firefox browser version?

hannesa2 commented 1 year ago

Hi,

About the Firefox the Signup with Google spins, can you please write in which environment do you work(Is it windows/ mac (which macOS name?) and which Firefox browser version?

=> https://github.com/jfrog/artifactory-client-java/issues/363

hannesa2 commented 1 year ago

In version 2.13.1 the error still exists