gpt4 book ai didi

java - 由于明显的类路径冲突而导致 jersey WadlAutoDiscoverable 转换错误?

转载 作者:行者123 更新时间:2023-12-02 10:12:41 29 4
gpt4 key购买 nike

我们有一个 Kafka Connect 项目,我们依赖 library它从 gitlab 获取数据。该库依赖于 Jersey 。卡夫卡还使用 Jersey 。启动连接器时,我们收到一个类转换错误,该错误似乎是由于 jersey 具有某种全局发现模式引起的,当 serverclient 处于同一位置时,该模式会发生冲突类路径。

org.gitlab4j.api.GitLabApiException: org.glassfish.jersey.server.wadl.internal.WadlAutoDiscoverable cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable
at org.gitlab4j.api.AbstractApi.handle(AbstractApi.java:615)
at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:193)
at poc.connector.gitlab.api.ExtendedIssuesApi.getIssues(GitlabExtendedApi.scala:34)
at poc.connector.gitlab.GitLabSourceTask.poll(GitLabSourceTask.scala:49)
at org.apache.kafka.connect.runtime.WorkerSourceTask.poll(WorkerSourceTask.java:244)
at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:220)
at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175)
at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: org.glassfish.jersey.server.wadl.internal.WadlAutoDiscoverable cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable
at java.util.TreeMap.compare(TreeMap.java:1295)
at java.util.TreeMap.put(TreeMap.java:538)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
at java.util.TreeSet.addAll(TreeSet.java:312)
at org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:599)
at org.glassfish.jersey.client.ClientConfig$State.configureAutoDiscoverableProviders(ClientConfig.java:403)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:450)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:419)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:319)
at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:382)
at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:370)
at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:191)
... 11 more


$ #inside of the plugin path of kafka connect:
$ find ./ | grep jersey | grep server Di 26 Feb 2019 15:46:41 CET
./schema-registry/jersey-server-2.27.jar
./confluent-kafka-mqtt/jersey-server-2.27.jar
./kafka/jersey-server-2.27.jar
./rest-utils/jersey-server-2.27.jar

我们如何配置代码以避免在连接应用程序过程中的某个地方使用了错误的类的问题?或者我们如何避免在 AutoDiscoverable 实现的上下文中出现转换错误?

最佳答案

我们的 Kafka Connect 连接器之一也遇到了类似的问题,我们通过在连接器中对 org.glassfish 进行着色来解决该问题。

我们将连接器打包为“uber JAR”,并将其放置在使用 plugin.path 设置配置的路径中。

另请参阅the Confluent docs for Kafka Connect关于这个话题。其中指出

... a plugin should never contain any libraries that are provided by Kafka Connect's runtime.

我们选择了阴影,您也可以通过不在连接器中封装 Jersey 来解决此问题。

关于java - 由于明显的类路径冲突而导致 jersey WadlAutoDiscoverable 转换错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54888135/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com