我正在尝试制作一个可以在运行时更改一些参数的 Mbean,但是在尝试调用操作时会发生以下错误:
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is: java.lang.ClassNotFoundException: weblogic.management.NoAccessRuntimeException > (no security manager: RMI class loader disabled)
我正在使用 weblogic y jconsole。
代码:
public class MyMBeanListener extends ApplicationLifecycleListener {
public void postStart(weblogic.application.ApplicationLifecycleEvent p1) {
try {
ObjectName mymbean =
new ObjectName("monitor:Name=MyMonitor,Type=MyMonitorMBean");
InitialContext ctx = new InitialContext();
MBeanServer server = (MBeanServer)ctx.lookup("java:comp/jmx/runtime");
MyMonitor monitor = new MyMonitor();
server.registerMBean(monitor, mymbean);
System.out.println(" MBean registered successfully!");
} catch (Exception e) {
e.printStackTrace();
}
}
public interface MyMonitorMBean {
public void setMessage(String msg);
}
public class MyMonitor implements MyMonitorMBean {
private String _con;
@Override
public synchronized void setMessage(String msg) {
_con = msg;
}
}