2013-10-13 56 views
0

我試圖讓可以改變在運行的幾個參數的Mbean的,但試圖調用時出現以下錯誤的操作時:的MBean operaciones錯誤的Weblogic

java.rmi.UnmarshalException: Error unmarshaling return; nested exception is: java.lang.ClassNotFoundException: weblogic.management.NoAccessRuntimeException > (no security manager: RMI class loader disabled) 

我使用WebLogicÿ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; 
    } 
    } 
+0

我們可以看到你的代碼嗎? –

+0

public class MyMonitor implements MyMonitorMBean {private String _con; @Override public synchronized void setMessage(String msg){_con = msg; } – Oxxi

+0

不確定weblogic是否有特殊的jmx支持,但是你需要用'@MXBean'來註釋MyMonitorBean接口嗎? – jtahlborn

回答

0

如果你把Weblogic的JAR文件在類路徑它應該工作,或者至少你會擺脫ClassNotFoundException的

我會放的weblogic.jar或wlfullclient.jar的(如果你有它),嘗試以類似於此的方式運行JConsole:

jconsole -J-Djava.class.path="Weblogic Lib Folder\weblogic.jar"