Search code examples
azuretomcatgoogle-cloud-vision

Running Google Cloud Vision from Linux Container on Azure


Using a Windows Server, Tomcat 8 and Java 7, I successfully use the Google Cloud Vision API to OCR a document.

When I do the same process (with the same libraries etc.) from a Linux Container on Azure, with Tomcat 9 and Java 8 then I get the following:

java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been > properly configured. > at >
 io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:162) > at 
io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:136) > at 
io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:124) > at 
io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:94) > at > 
io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DefaultNettyTransportCreationParamsFilterFactory.<init>(NettyChannelBuilder.java:521) > 2019-10-24T13:33:37.831210199Z at > 
io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DefaultNettyTransportCreationParamsFilterFactory.<init>(NettyChannelBuilder.java:514) > 2019-10-24T13:33:37.832461409Z at > 
io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.<init>(NettyChannelBuilder.java:453) > at > 
io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:312) > at > 
io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:324) > at > 
com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:165) > 2019-10-24T13:33:37.834701725Z at > 
com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:130) > 2019-10-24T13:33:37.835210729Z at > 
com.google.api.gax.rpc.ClientContext.create(ClientContext.java:122) > at > 
com.google.cloud.vision.v1.stub.GrpcImageAnnotatorStub.create(GrpcImageAnnotatorStub.java:62) > at > 
com.google.cloud.vision.v1.ImageAnnotatorSettings.createStub(ImageAnnotatorSettings.java:101) > at > 
com.google.cloud.vision.v1.ImageAnnotatorClient.<init>(ImageAnnotatorClient.java:130) > at > 
com.google.cloud.vision.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:111) > at > 
com.google.cloud.vision.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:102)

Any ideas?

My GOOGLE_APPLICATION_CREDENTIALS are set correctly:

SCREENSHOT GOOGLE_APPLICATION_CREDENTIALS

From my research it seems that there might be some kind of compatibility issue, perhaps with the versions of netty that I am using.

SCREENSHOT NETTY VERSIONS


Solution

  • I have found the problem. Linux Web Apps was configured to use Java 8, whereas my Eclipse environment had jdk-12.0.2.

    When I changed the Web Apps container to Java 11 (and to Tomcat 9.0) it then worked!

    Azure Portal

    Thank you to @Kolban for providing a link to a troubleshooting page which included the following:

    If you are on a 32-bit operating system, using Java 11+ may be the easiest solution, as ALPN was added to Java in Java 9. If on 32-bit Windows, Conscrypt is an option. Otherwise you need to build your own 32-bit version of netty-tcnative.