access Mbeans on weblogic

后端 未结 1 1982
旧巷少年郎
旧巷少年郎 2021-01-07 01:19

From the documentation of oracle :

Domain Runtime MBean Server : This MBean server also acts as a single point of access for MBeans that reside on M

1条回答
  •  星月不相逢
    2021-01-07 01:52

    maybe my question wasnt clear but i found an answer and i will share it here now : Question summary : i need to access custom mBeans exists in a managed server by connecting to the administration server from a client application.

    Answer : to do that you need to deploy your application to the administrator server (i tried remote but it didn't work )

    you need to connect to the DomainRuntimeServiceMBean because it provide a common access point for navigating to all runtime and configuration MBeans in the domain .

    when searching for the Object name add Location=

    here is the code:

        Hashtable props = new Hashtable();
              props.put(Context.INITIAL_CONTEXT_FACTORY,
                        "weblogic.jndi.WLInitialContextFactory");
    
              props.put(Context.SECURITY_PRINCIPAL,   "");
              props.put(Context.SECURITY_CREDENTIALS, "");
              Context ctx = new InitialContext(props);
      MBeanServer    server = (MBeanServer)ctx.lookup("java:comp/env/jmx/domainRuntime");
    
    
             ObjectName on =new ObjectName("com.:Name=,Type=,Location=");
             boolean boolresult=(Boolean)server.invoke(on, "",
             new Object[]{"","",""}
             ,new String[]{"java.lang.String","java.lang.String","java.lang.String"}); 
             out.print(boolresult);
    

    0 讨论(0)
提交回复
热议问题