Skip to content

No functional channel provider found #2085

Closed

Description

@mamdouhweb

While trying to run google-vision-api with a Scala project I'm getting the following exception.

io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact
        at io.grpc.ManagedChannelProvider.provider(ManagedChannelProvider.java:126)
        at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:45)
        at com.google.api.gax.grpc.InstantiatingChannelProvider.createChannel(InstantiatingChannelProvider.java:129)
        at com.google.api.gax.grpc.InstantiatingChannelProvider.getChannel(InstantiatingChannelProvider.java:116)
        at com.google.api.gax.grpc.ChannelAndExecutor.create(ChannelAndExecutor.java:65)
        at com.google.api.gax.grpc.ClientSettings.getChannelAndExecutor(ClientSettings.java:77)
        at com.google.cloud.vision.spi.v1.ImageAnnotatorClient.<init>(ImageAnnotatorClient.java:120)
        at com.google.cloud.vision.spi.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:111)
        at com.google.cloud.vision.spi.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:102)

I have tried changing the grpc-netty version and the http2 dependency from netty codec version as well. I also tried excluding the library and replacing it with grpc-okhttp to no hope!

Appreciate any help here

Activity

  1. added
    api: visionIssues related to the Cloud Vision API.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on May 23, 2017
  2. vam-google commented on May 23, 2017

    @vam-google
    Contributor

    Hi @mamdouhweb, please provide your project dependencies configuration (i.e. which artifacts and versions you depend on). Also, does it work if you try to do the same thing in java (i.e. is it specific to scala)?

  3. mamdouhweb commented on May 23, 2017

    @mamdouhweb
    Author

    @vam-google thanks for the quick reply. I haven't tried it in Java, I'm assuming it works as you guys have it in the examples.
    as for my dependency list:

    "joda-time" % "joda-time" % versions.jodaTime
    "com.typesafe.akka" %% "akka-http-core" % versions.akkaHttpCore,
          "com.typesafe.akka" %% "akka-http" % versions.akkaHttp,
          "com.typesafe.akka" %% "akka-http-testkit" % versions.akkaHttpTestKit,
          "com.typesafe.akka" %% "akka-http-spray-json" % versions.akkaHttpSprayJson,
          "com.typesafe.akka" %% "akka-http-jackson" % versions.akkaHttpJackson,
          "com.typesafe.akka" %% "akka-slf4j" % versions.akkaSlf4j,
          "com.typesafe.scala-logging" %% "scala-logging-slf4j" % versions.slf4jScalaLogging,
          "org.slf4j" % "slf4j-api" % versions.slf4jAPI,
          "org.slf4j" % "log4j-over-slf4j" % versions.slf4jLog4j,
          "ch.qos.logback" % "logback-classic" % versions.logbackClassic,
          "ch.qos.logback" % "logback-core" % versions.logbackCore,
          "com.spotify" % "async-google-pubsub-client" % versions.cloudPubSub,
          "com.google.cloud" % "google-cloud-vision" % versions.cloudVision
    

    I also ran dependency tree command and I can see grpc-netty, here's a screen shot that might be helpful

    screen shot 2017-05-23 at 5 38 07 pm

  4. mamdouhweb commented on May 23, 2017

    @mamdouhweb
    Author

    Addendum:
    Cloud vision version is

    val cloudVision = "0.18.0-beta"

    Further, here's the code I'm using to test the library

    import com.google.cloud.vision.spi.v1.{ImageAnnotatorClient, ImageAnnotatorSettings}
    import com.google.cloud.vision.v1.Feature.Type
    import com.google.cloud.vision.v1.{AnnotateImageRequest, Feature, Image, ImageSource}
    import com.google.protobuf.Descriptors.FieldDescriptor
    import com.spotify.google.cloud.pubsub.client.Message
    import com.typesafe.scalalogging.slf4j.LazyLogging
    import org.threeten.bp.Duration
    
    import scala.collection.JavaConversions._
    import scala.collection.mutable
    
    def detectImageLabels(
          fileName: String): mutable.Buffer[Seq[mutable.Map[FieldDescriptor, String]]] = {
    
        val imageAnnotatorSettingsBuilder =
          ImageAnnotatorSettings.defaultBuilder()
    
        imageAnnotatorSettingsBuilder
          .batchAnnotateImagesSettings()
          .getRetrySettingsBuilder
          .setTotalTimeout(Duration.ofSeconds(30))
    
        val settings = imageAnnotatorSettingsBuilder.build()
    
        val vision = ImageAnnotatorClient.create(settings)
    
        val gcsPath = "gs://" + bucketName + "/" + fileName
    
        val imageSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build()
    
        val image = Image.newBuilder().setSource(imageSource).build()
    
        val feature = Feature.newBuilder().setType(Type.LABEL_DETECTION).build()
    
        val request =
          AnnotateImageRequest.newBuilder().addFeatures(feature).setImage(image).build()
    
        val requests: List[AnnotateImageRequest] = List(request)
    
        val response = vision.batchAnnotateImages(requests)
    
        val responses = response.getResponsesList
    
        responses.map { response =>
          if (!response.hasError) {
            response.getLabelAnnotationsList.map { annotation =>
              annotation.getAllFields.map { field =>
                logger.info("label detected: " + field._1.getFullName + " " + field._2.toString)
                (field._1, field._2.toString)
              }
            }
          } else {
            logger.error("error detecting labels for Image: " + fileName)
            List()
          }
        }
      }
    
  5. mamdouhweb commented on May 23, 2017

    @mamdouhweb
    Author

    After a fight with this issue, it is fixed now!

    The main cause of the issue is the horrifying combination between io.netty.versions.properties and sbt assembly

    That said, this is definitely not a bug, and I apologize for taking your time @vam-google
    For anyone in the future who might face the same problem, just add the following line in your projectAssemblySettings

    case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.rename 
    
    // Note: using any of the following MergeStrategies (last, first or discard) will definitely cause issues, I haven't tried merge but you can definitely try it yourself :)
  6. vam-google commented on May 23, 2017

    @vam-google
    Contributor

    Good to hear that it is not a bug =). Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: visionIssues related to the Cloud Vision API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions