Azure / autorest-clientruntime-for-java

The runtime libraries for AutoRest generated Java clients.
MIT License
20 stars 59 forks source link

okhttp dependency issu: java.lang.NoSuchMethodError: okhttp3.Cookie.toString(Z)Ljava/lang/String; #688

Open andxu opened 4 years ago

andxu commented 4 years ago

copied from : https://github.com/microsoft/azure-gradle-plugins/issues/65

Execution failed for task ':azureFunctionsDeploy'.
> okhttp3.Cookie.toString(Z)Ljava/lang/String;

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':azureFunctionsDeploy'.
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:207)
  at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:205)
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:186)
  at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
  at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
  at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
  at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
  at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
  at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:409)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94)
  at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
  at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:356)
  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
  at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
  at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
  at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.NoSuchMethodError: okhttp3.Cookie.toString(Z)Ljava/lang/String;
  at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45)
  at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207)
  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:86)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.rest.retry.RetryHandler.intercept(RetryHandler.java:75)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.rest.interceptors.CustomHeadersInterceptor.intercept(CustomHeadersInterceptor.java:140)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.rest.interceptors.UserAgentInterceptor.intercept(UserAgentInterceptor.java:83)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.azure.credentials.AzureTokenCredentialsInterceptor.intercept(AzureTokenCredentialsInterceptor.java:40)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.azure.management.resources.fluentcore.utils.ResourceManagerThrottlingInterceptor.intercept(ResourceManagerThrottlingInterceptor.java:54)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor.intercept(ProviderRegistrationInterceptor.java:40)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.rest.interceptors.BaseUrlHandler.intercept(BaseUrlHandler.java:43)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at com.microsoft.rest.interceptors.RequestIdHeaderInterceptor.intercept(RequestIdHeaderInterceptor.java:29)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
  at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:194)
  at okhttp3.RealCall.execute(RealCall.kt:67)
  at retrofit2.OkHttpCall.execute(OkHttpCall.java:188)
  at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:40)
  at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:24)
  at retrofit2.adapter.rxjava.BodyOnSubscribe.call(BodyOnSubscribe.java:36)
  at retrofit2.adapter.rxjava.BodyOnSubscribe.call(BodyOnSubscribe.java:28)
  at rx.Observable.unsafeSubscribe(Observable.java:10327)
  at rx.Completable$10.call(Completable.java:588)
  at rx.Completable$10.call(Completable.java:567)
  at rx.Completable.unsafeSubscribe(Completable.java:2035)
  at rx.Completable.unsafeSubscribe(Completable.java:2083)
  at rx.Completable.unsafeSubscribe(Completable.java:2067)
  at rx.Completable$32.call(Completable.java:2253)
  at rx.Completable$32.call(Completable.java:2250)
  at rx.Observable.unsafeSubscribe(Observable.java:10327)
  at rx.internal.operators.OnSubscribeRedo$2.call(OnSubscribeRedo.java:273)
  at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(TrampolineScheduler.java:73)
  at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.schedule(TrampolineScheduler.java:52)
  at rx.internal.operators.OnSubscribeRedo$5.request(OnSubscribeRedo.java:361)
  at rx.Subscriber.setProducer(Subscriber.java:209)
  at rx.internal.operators.OnSubscribeRedo.call(OnSubscribeRedo.java:353)
  at rx.internal.operators.OnSubscribeRedo.call(OnSubscribeRedo.java:47)
  at rx.Observable.unsafeSubscribe(Observable.java:10327)
  at rx.Completable$10.call(Completable.java:588)
  at rx.Completable$10.call(Completable.java:567)
  at rx.Completable.unsafeSubscribe(Completable.java:2035)
  at rx.Completable.await(Completable.java:1034)
  at com.microsoft.azure.management.appservice.implementation.FunctionAppImpl.zipDeploy(FunctionAppImpl.java:625)
  at com.microsoft.azure.common.deploytarget.DeployTarget.zipDeploy(DeployTarget.java:49)
  at com.microsoft.azure.common.handlers.artifact.ZIPArtifactHandlerImpl.publish(ZIPArtifactHandlerImpl.java:50)
  at com.microsoft.azure.common.function.handlers.artifact.RunFromZipArtifactHandlerImpl.publish(RunFromZipArtifactHandlerImpl.java:38)
  at com.microsoft.azure.plugin.functions.gradle.handler.DeployHandler.execute(DeployHandler.java:116)
  at com.microsoft.azure.plugin.functions.gradle.task.DeployTask.deploy(DeployTask.java:46)

Workaround:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
       classpath("com.squareup.okhttp3:okhttp-urlconnection:4.9.0")
    }
}

JDK: 1.8 Plugin version: 1.4.0

andxu commented 4 years ago

okhttp has a new version: 4.9.0, could java sdk side update to use this new version?

+--- com.microsoft.azure:azure:1.36.2 | +--- com.microsoft.azure:azure-client-runtime:1.7.8 | | --- com.microsoft.rest:client-runtime:1.7.8 | | +--- com.google.guava:guava:20.0 -> 29.0-jre () | | +--- com.squareup.retrofit2:retrofit:2.6.4 | | | --- com.squareup.okhttp3:okhttp:3.12.0 -> 3.12.12 | | | --- com.squareup.okio:okio:1.15.0 | | +--- com.squareup.okhttp3:okhttp:3.12.12 () | | +--- com.squareup.okhttp3:logging-interceptor:3.12.12 | | | --- com.squareup.okhttp3:okhttp:3.12.12 () | | +--- com.squareup.okhttp3:okhttp-urlconnection:3.12.12 | | | --- com.squareup.okhttp3:okhttp:3.12.12 ()

weidongxu-microsoft commented 4 years ago

@andxu

okhttp 4 is unlikely be supported by this library, since clientruntime had to support Java 7 (while okhttp4 requires Java8).

If you had a chance, please try latest ARM SDK https://aka.ms/azsdk/java/mgmt It is at present in preview, so some interface will change after GA (e.g. Azure -> AzureResourceManager).