access Mbeans on weblogic

非 Y 不嫁゛ 提交于 2019-12-01 00:54:46

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,   "<userName>");
          props.put(Context.SECURITY_CREDENTIALS, "<password>");
          Context ctx = new InitialContext(props);
  MBeanServer    server = (MBeanServer)ctx.lookup("java:comp/env/jmx/domainRuntime");


         ObjectName on =new ObjectName("com.<companyName>:Name=<Name>,Type=<Type>,Location=<managed_server_name>");
         boolean boolresult=(Boolean)server.invoke(on, "<method_Name>",
         new Object[]{"<ARG1>","<ARG2>","<ARG3>"}
         ,new String[]{"java.lang.String","java.lang.String","java.lang.String"}); 
         out.print(boolresult);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!