シナリオは次のとおりです。
- アプリケーション サーバー: Weblogic 12.2.1.2
- アプリケーション: エンタープライズ アプリケーション
作業シナリオ:
- 管理サーバーにデプロイされたアプリケーション。
- JConsole は MXBean を正しく表示します。
動作していないシナリオ:
- 2 つの管理対象サーバーのクラスタにデプロイされたアプリケーション。
- 各管理対象サーバーで構成された JMX。
- JConsole に MXBean が表示されません。
私のソースコード関連のフラグメントの下。
public class JpaCacheDescriptor {
private String name;
private int size;
@ConstructorProperties({ "name", "size" })
public JpaCacheDescriptor(String name, int size) {
this.name = name;
this.size = size;
}
// Not relevant
}
public interface JpaCacheManager {
List<JpaCacheDescriptor> getCaches();
void clearAll();
}
@Slf4j
public class JpaCacheManagerImpl
extends StandardMBean
implements JpaCacheManager
{
private static ObjectName objectName;
private static MBeanServer getMBeanServer()
throws NamingException
{
InitialContext initialContext = new InitialContext();
return (MBeanServer)initialContext.lookup("java:comp/jmx/runtime");
}
public JpaCacheManagerImpl()
throws NotCompliantMBeanException
{
super(JpaCacheManager.class);
}
public static void register() {
log.info("{ }");
try {
objectName = new ObjectName(String.format(
"${wls.jmx.root}:name=${application.name},version=${application.version},node=%s,type=%s",
System.getProperty("weblogic.Name"),
JpaCacheManager.class.getSimpleName()
));
JpaCacheManagerImpl jpaCacheMBean = new JpaCacheManagerImpl();
StandardMBean standardMBean = new StandardMBean(jpaCacheMBean, JpaCacheManager.class, true); // Force MXBean which is not inferred by @MXBean and MXBean prefix!!!
getMBeanServer().registerMBean(standardMBean, objectName);
log.info("Registered as \"{}\".", objectName.getCanonicalName());
} catch (
InstanceAlreadyExistsException
| MalformedObjectNameException
| MBeanRegistrationException
| NamingException
| NotCompliantMBeanException exception
) {
objectName = null;
log.error(exception.getMessage(), exception);
}
}
public static void unregister() {
log.info("{ }");
if (null == objectName) {
log.warn("MBean not registered!");
} else {
try {
getMBeanServer().unregisterMBean(objectName);
log.info("MBean unregistered.");
}
catch (
InstanceNotFoundException
| MBeanRegistrationException
| NamingException exception
) {
log.error(exception.getMessage(), exception);
}
}
}
@Override
public List<JpaCacheDescriptor> getCaches() {
// Not relevant
}
@Override
public void clearAll() {
// Not relevant
}
}
解決策を探すのに多くの時間を費やしましたが、運がありません!
前もって感謝します。