首页 > 解决方案 > JMX 和不同的类加载器

问题描述

我的项目是多模块的,结构如下:

问题是插件部分使用与代理不同的类加载器。因此我收到

java.lang.ClassCastException: class com.github.lppedd.jmx.FeaturesMBean$Feature cannot be cast to class com.github.lppedd.jmx.FeaturesMBean$Feature
    (com.github.lppedd.jmx.FeaturesMBean$Feature is in unnamed module of loader 'app';
     com.github.lppedd.jmx.FeaturesMBean$Feature is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @35962a94)

被指控的 MBean 是

public interface FeaturesMBean {
  List<Feature> availableFeatures();

  class Feature implements Serializable {
    private static final long serialVersionUID = 1L;

    public final String name;
    public final String description;

    public Feature(final String name, final String description) {
      this.name = name;
      this.description = description;
    }
  }
}

我应该如何处理这个问题?

标签: jvmclassloaderjmxjavaagents

解决方案


推荐阅读