jmx

RMI and JMX Socket Factories

断了今生、忘了曾经 提交于 2019-12-06 03:29:17
I'm trying to start an embedded JMX server in my java app. I want to use the same port for the RMI Registry and for the actual RMI traffic (or JMX traffic if you like). Apparently this is possible since the RMI Registry is merely a Remote Object itself . The added difficulty is that I need to use Socket Factories because I need to bind to a specific NIC. I start off by: int registryPort = 3012; int jmxPort = 3012; // use the same port and here's my server socket factory. Pretty straight-forward stuff: public class MyRMIServerSocketFactory implements RMIServerSocketFactory { private final

How to integrate JMX with Spring?

眉间皱痕 提交于 2019-12-06 02:01:45
I have simple class about JMX: Interface HelloMBean: public interface HelloMBean { public void sayHello(); public String getName(); public void setName(String name); public String conCat(String s1, String s2); } Class Hello implements from interface HelloMBean: import javax.management.AttributeChangeNotification; import javax.management.Notification; import javax.management.NotificationBroadcasterSupport; public class Hello extends NotificationBroadcasterSupport implements HelloMBean { private String m_name; @Override public void sayHello() { System.out.print("I say hello"); } @Override public

Detecting newly registered MBeans

扶醉桌前 提交于 2019-12-06 01:35:35
问题 I'm using the platform MBeans server in Java 1.6, running in an OSGi container. Using the MBeans for statistic counters and events mainly. The implementation of them are in one bundle, but they're instantiated in several other bundles. Every MBean autoregisters itself with the platform MBean server. The problem is that when I attach via JMX and query for MBeans, I only get the ones that are currently registered, and they wont be registered until they've been instantiated (either because

Spring: Cannot connect to a JMX Server using RMI from behind a firewall

瘦欲@ 提交于 2019-12-05 16:17:35
My Spring application is running on a machine that is behind a NAT firewall (pfSense). The machine's internal IP is a.b.c.d , and the NAT IP is w.x.y.z The Spring configuration's serviceUrl is set to my internal IP ( a.b.c.d ) on port 1100 , and when I start the application, I provide the following switches: -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=w.x.y.z -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false As shown above, I set -Djava.rmi.server

How to get memory usage of tomcat 7 using JMX API?

为君一笑 提交于 2019-12-05 14:26:13
Is it possible to get the memory usage statistics of a tomcat server using JMX API. Which Mbean can provide me this info? I am stuck at the formation of ObjectName in the below code JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2020/jmxrmi"); JMXConnector jmxc = JMXConnectorFactory.connect(url); MBeanServerConnection server = jmxc.getMBeanServerConnection(); Object o = jmxc.getMBeanServerConnection().getAttribute( new ObjectName("-----"); Wonder how jconsole draws the memory graphs, any pointers for the source code? MBeanServer connection = ManagementFactory

JMX Port dynamic allocation

戏子无情 提交于 2019-12-05 13:33:51
I have 16 Java processes with the same main method and arguments running on one machine. I wish to monitor these remotely thru JConsole. Hard coding port numbers like -Dcom.sun.management.jmxremote.port=5000 won't work because these processes are using same configuration and they can't work with same port. Is it possible for the JVM to select a different port dynamically for each of the 16 processes? MarianP Using RMI Connector might be the way as you may specify URL of your agent. In case you'd need it, you may create RMI registry programatically using: java.rmi.registry.LocateRegistry

Requesting a stack trace for a Java ThreadInfo?

感情迁移 提交于 2019-12-05 11:22:58
I have an application that calls getStackTrace() on a java.lang.management.ThreadInfo object, but the StackTraceElement array produced by the invocation is zero length. Inspecting the Javadoc shows this (emphasis mine): public StackTraceElement[] getStackTrace() Returns the stack trace of the thread associated with this ThreadInfo. If no stack trace was requested for this thread info, this method will return a zero-length array . If the returned array is of non-zero length then the first element of the array represents the top of the stack, which is the most recent method invocation in the

Description for Standard MBean

房东的猫 提交于 2019-12-05 10:40:21
I want to make my Standard MBean verbose in JBoss jmx-console. DynamicMBean has getMBeanInfo() to do it. Method return MBeanInfo with description of MBean. But how I can to do the same thing for Standard MBean? E.g. I have following MBean interface: public interface MyMBean { String f(); } ... with following implementation: public class My implements MyMBean { public String f() { return "test"; } } What should be done to add description in such example? Thanks Roland Huß For StandardMBeans there is no way for adding description or other meta information. From the JavaDoc of MBeanInfo : The

How to detect if a Java System property has changed?

陌路散爱 提交于 2019-12-05 06:40:15
I would like to know when a System property is changed. I have an application, in an application server, that somehow is changing a system property ( System.setProperty() I think). I was taking a look and I have found different approaches: JPDA? Observer & Observable? Property change listener? JMX? Any suggestions? Thanks in advance. You can replace the system Properties with your own custom subclass. MyProperties newProps = new MyProperties(System.getProperties()); System.setProperties(newProps); Then, just write a subclass of Properties which hooks the relevant methods. If you primarily want

Web app deployment in Tomcat

主宰稳场 提交于 2019-12-05 06:25:35
Does Tomcat use a different Java Virtual Machine (JVM) for each web application running in its container, or does all web applications in Tomcat run under the same JVM? So for a specific example: if a web application under webapps, enables JMX programmatically (via System properties) does this mean that JMX is enabled for all web applications running in the container? I believe this is the case, but would like to confirm. This question came up from my problem in this thread: question on tomcat and jmx . Any input on the subject is appreciated. Tomcat runs in a single JVM, so every app deployed