我在带有Java 11的apache karaf 4.2.6中有一个模块,用于验证Google Play中的购买收据。我正在使用androidpublisher。
当它第一次发送请求时,我在OpenCensusUtils类中收到一个错误:
androidPublisher.purchases().products().get(packageName, productId, purchaseToken).execute()
java.lang.ClassNotFoundException: io.opencensus.trace.propagation.TextFormat not found by wrap_file__Users_USER_NAME_.m2_repository_io_opencensus_opencensus-contrib-http-util_0.22.1_opencensus-contrib-http-util-0.22.1.jar
在随后的时间private final Tracer tracer = OpenCensusUtils.getTracer()
上,com.google.api.client.http.HttpRequest类出现错误:
java.lang.NoClassDefFoundError: Could not initialize class com.google.api.client.http.OpenCensusUtils
这里是依赖项:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-androidpublisher</artifactId>
<version>v3-rev92-1.25.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.29.2</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
<version>0.22.1</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-contrib-http-util</artifactId>
<version>0.22.1</version>
</dependency>
另外google-api-client
,google-http-client-jackson2
和google-oauth-client
的版本为1.29.2
在karaf中,我看到库opencensus-api
正在导出包含类TextFormat的包io.opencensus.trace.propagation
。
我在做什么错了?
答案 0 :(得分:0)
我通过将io.opencensus和io.grpc添加到模块构建区域的Private-Package中来解决,如下所示。它使它们嵌入本地。
....
<build>
<plugins>
<plugin>
....
<configuration>
<instructions>
<Bundle-SymbolicName> ${project.artifactId} </Bundle-SymbolicName>
<Private-Package>
META-INF.services;-split-package:=merge-first,
com.google.*;-split-package:=merge-first,
io.opencensus.*;-split-package:=merge-first,
io.grpc.*;-split-package:=merge-first
</Private-Package>
....