无法将类型 id 'org.redisson.codec.SmileJacksonCodec' 解析为 `org.redisson.client.codec.Codec` 的子类型:找不到这样的类

问题描述 投票:0回答:0

我正在尝试加载具有 redis 配置的 yaml 配置文件,我看到以下错误:

这里发生的是 org.redisson.client.codec.Codec 是接口,org.redisson.codec.SmileJacksonCodec 是第 3 级继承类,我能够在独立代码时成功运行它但是当用 docker image 打包时得到关注错误。这个问题类似于 Jackson 1.8.5 (for JSON) does not deserialize: "no such class found"

HTTP/1.1 400 Bad Request
Date: Mon, 08 May 2023 02:51:50 GMT
Content-Type: text/plain
Content-Length: 295
Server: Jetty(9.4.50.v20221201)

Could not resolve type id 'org.redisson.codec.SmileJacksonCodec' as a subtype of `org.redisson.client.codec.Codec`: no such class found
 at [Source: (sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream); line: 20, column: 8] (through reference chain: org.redisson.config.Config["codec"])

以下是代码

尝试构建 RedisClient 如下:

def createRedisClient() : RedissonClient = {
      val uri = this.getClass.getClassLoader.getResourceAsStream("redis-config.yaml")
        val config: Config = Config.fromYAML(uri)
        codec.foreach(config.setCodec)
        logger.info(s"RedisClientPool : ${config.toJSON}")
        Redisson.create(config)
}

redis-config.yaml 看起来像

---
singleServerConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 30000
  timeout: 30000
  retryAttempts: 3
  retryInterval: 1500
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  address: "redis://redis:6379"
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 5
  connectionMinimumIdleSize: 8
  connectionPoolSize: 8
  database: 1
  dnsMonitoringInterval: 5000
threads: 2
nettyThreads: 4
codec: !<org.redisson.codec.SmileJacksonCodec> {}
transportMode: "NIO"

org.redisson.codec.SmileJacksonCodec 和 org.redisson.client.codec.Codec 都在类路径上可用

正在从码头服务器调用请求,由于此失败,它变成了错误的请求并抛出 400 http。

任何线索请建议。

我还验证了两个类的详细日志如下所示

[Loaded org.redisson.client.codec.Codec from file:/opt/mycomosi/jars/topology-cache-management.jar]
[Loaded org.redisson.codec.SmileJacksonCodec from file:/opt/mycomosi/jars/topology-cache-management.jar]
scala apache-spark jetty redisson
© www.soinside.com 2019 - 2024. All rights reserved.