【问题标题】:Getting java.lang.IllegalAccessError when attempting to access Firestore collection尝试访问 Firestore 集合时出现 java.lang.IllegalAccessError
【发布时间】:2020-04-24 12:15:24
【问题描述】:

当我尝试使用直接运行程序从 Apache Beam 调用我的 Spring 应用程序时,出现以下异常。

org.apache.beam.sdk.Pipeline$PipelineExecutionException: 
java.lang.IllegalAccessError: class 
io.grpc.internal.CensusTracingModule$TracingClientInterceptor tried to access 
private field io.opencensus.trace.unsafe.ContextUtils.CONTEXT_SPAN_KEY 
(io.grpc.internal.CensusTracingModule$TracingClientInterceptor and 
io.opencensus.trace.unsafe.ContextUtils are in unnamed module of loader 
java.net.URLClassLoader @72906e)

这行代码在微服务中。我创建了一个 jar 并在 Apache Beam 中添加了该依赖项。

这是导致错误的行:

 ApiFuture<QuerySnapshot> future = firestore.collection("dev-project-tablename")
                    .whereEqualTo("key", key).get();

在 Apache Beam 中,我使用以下方法实例化了 Firestore 对象:

Firestore fireStore = FirestoreOptions.getDefaultInstance().getService();

【问题讨论】:

    标签: google-cloud-platform google-cloud-firestore apache-beam java-11


    【解决方案1】:

    您很可能将不同版本的 opencensus 二进制文件作为临时依赖项。如果您的项目是基于 maven 的,您可以使用 maven dependency:tree 列出所有依赖项。也可以查看这个问题:https://github.com/firebase/firebase-admin-java/issues/310

    要解决它,您必须提高一些 Firebase 依赖项的版本,因为您没有添加这些详细信息,所以不确定是哪个版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-15
      • 2020-04-15
      • 1970-01-01
      • 2018-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-11
      相关资源
      最近更新 更多