title: gRPC exception related with NameResolverProvider
body: <p>I have a gRPC server written in Java, that is trying to access Firestore and other services, through a Service Account that has Project Owner roles. The server ran successfully plenty of times, but when I tried to run again, this happened:</p>
  
  <pre class="lang-java prettyprint-override"><code>Exception in thread "main" java.util.ServiceConfigurationError: io.grpc.NameResolverProvider: Provider io.grpc.grpclb.SecretGrpclbNameResolverProvider$Provider could not be instantiated
      at java.util.ServiceLoader.fail(ServiceLoader.java:232)
      at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
      at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
      at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
      at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
      at io.grpc.ServiceProviders.loadAll(ServiceProviders.java:67)
      at io.grpc.NameResolverRegistry.getDefaultRegistry(NameResolverRegistry.java:101)
      at io.grpc.internal.AbstractManagedChannelImplBuilder.&lt;init&gt;(AbstractManagedChannelImplBuilder.java:107)
      at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.&lt;init&gt;(NettyChannelBuilder.java:136)
      at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.&lt;init&gt;(NettyChannelBuilder.java:131)
      at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.forAddress(NettyChannelBuilder.java:117)
      at io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:37)
      at io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:23)
      at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:39)
      at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:270)
      at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.access$1500(InstantiatingGrpcChannelProvider.java:71)
      at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider$1.createSingleChannel(InstantiatingGrpcChannelProvider.java:202)
      at com.google.api.gax.grpc.ChannelPool.create(ChannelPool.java:72)
      at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:209)
      at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:192)
      at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:155)
      at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:122)
      at com.google.cloud.firestore.spi.v1.GrpcFirestoreRpc.&lt;init&gt;(GrpcFirestoreRpc.java:122)
      at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:90)
      at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:82)
      at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:561)
      at com.google.cloud.firestore.FirestoreOptions.getFirestoreRpc(FirestoreOptions.java:385)
      at com.google.cloud.firestore.FirestoreImpl.&lt;init&gt;(FirestoreImpl.java:67)
      at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:73)
      at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:66)
      at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:541)
      at services.FirestoreServiceActions.&lt;init&gt;(FirestoreServiceActions.java:25)
      at CNTextServer.main(CNTextServer.java:47)
  Caused by: java.lang.VerifyError: Cannot inherit from final class
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
      at java.lang.Class.getConstructor0(Class.java:3075)
      at java.lang.Class.newInstance(Class.java:412)
      at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
      ... 30 more
  </code></pre>
  
  <p>To simplify things and to turnaround some major problems that may happen on IntelliJ Idea,
  I've created a much simpler (Maven) project that just has some code to start the server, and it worked fine, the server runs perfectly.
  Although, when I add the line that initializes the Firestore service, the same Exceptions are thrown.</p>
  
  <p>I have an environment variable (GOOGLE_APPLICATION_CREDENTIALS) pointing to a key of a service account that has Project Owner roles, just like I've mentioned before. I've also tried the FileInputStream alternative, pointing to the key, with no success.</p>
  
  <p>The code of my simpler (Maven) project is:</p>
  
  <pre class="lang-java prettyprint-override"><code>
  private static final int SERVICE_PORT = 8000;
  private Firestore firestoreService
  
  public static void main(String[] args) {
          try {
              System.out.println("--&gt; SETTING UP THE SERVER...");
  
              GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(SERVICE_ACCOUNT_KEY_PATH));
  
              this.firestoreService = FirestoreOptions.newBuilder().setCredentials(credentials).build().getService();
  
              Server service = ServerBuilder
                      .forPort(SERVICE_PORT)
                      .addService(new CNTextServer())
                      .build();
  
              service.start();
  
              System.out.println("--- SERVER STARTED. LISTENING ON PORT " + SERVICE_PORT);
              System.out.println("--&gt; PRESS 'ENTER' TO STOP THE SERVER");
              Scanner scanner = new Scanner(System.in);
              scanner.nextLine();
  
              System.out.println("&lt;-- SERVER SHUTTING DOWN...");
              service.shutdown();
          } catch (Exception ex) {
              System.out.println("### EXCEPTION ON SERVER.MAIN() ###\n" + ex.getMessage());
          }
      }
  </code></pre>
  
  <p>The dependencies on the Maven pom.xml file are:</p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.grpc&lt;/groupId&gt;
              &lt;artifactId&gt;grpc-netty-shaded&lt;/artifactId&gt;
              &lt;version&gt;1.28.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.grpc&lt;/groupId&gt;
              &lt;artifactId&gt;grpc-protobuf&lt;/artifactId&gt;
              &lt;version&gt;1.28.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.grpc&lt;/groupId&gt;
              &lt;artifactId&gt;grpc-stub&lt;/artifactId&gt;
              &lt;version&gt;1.28.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;google-cloud-firestore&lt;/artifactId&gt;
              &lt;version&gt;1.34.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;google-cloud-storage&lt;/artifactId&gt;
              &lt;version&gt;1.108.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;google-cloud-pubsub&lt;/artifactId&gt;
              &lt;version&gt;1.106.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;google-cloud-compute&lt;/artifactId&gt;
              &lt;version&gt;0.118.0-alpha&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;google-cloud-vision&lt;/artifactId&gt;
              &lt;version&gt;1.99.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;google-cloud-translate&lt;/artifactId&gt;
              &lt;version&gt;1.94.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;leic.cn.li62d-g04&lt;/groupId&gt;
              &lt;artifactId&gt;CNTextContract&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${basedir}/../CNTextContract/target/CNTextContract-1.0-SNAPSHOT.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>