-
1. Re: Monitor MBean from remote location
sgturner Jul 18, 2002 12:19 PM (in response to krasheed)You might want to think about upgrading to JBoss 3.0.0 Final.
-
2. Re: Monitor MBean from remote location
juha Jul 18, 2002 1:58 PM (in response to krasheed)Is there a firewall between the client and the remote mbean server?
-- Juha -
3. Re: Monitor MBean from remote location
adrian.brock Jul 18, 2002 2:28 PM (in response to krasheed)Hi,
1) You also need to create the StringMonitor
on the remote MBeanServer using the RMIAdaptor's
createMBean() and setAttributes().
Roll on JSR160. :-)
2) You need to invoke start() on the StringMonitor.
3) You need to add the notification to the ObjectName
of the StringMonitor.
4) Is Object Serializable? I don't think your handback will pass over the network?
In anycase, I don't think this worked in the beta.
The notification source wasn't set to the ObjectName of
the StringMonitor so the notification probably wouldn't
come back over the network. :-(
Regards,
Adrian -
4. Re: Monitor MBean from remote location
krasheed Jul 19, 2002 2:04 AM (in response to krasheed)Can you demostrate this by a piece of code which would create StringMonitor on the remote MBeanServer using RMiAdaptor's createMBean.
I am invoking start() on the StringMonitor.
Which object you are refering to be serialized? Please describe this in bit detail.
What changes must I have to made in the code in order to run the app accordingly. Please assist me with the help of sample code.
It's an urgent task..........I have already slipped my deadline.
THANK YOU ALL FOR THE HELP IN RESOLVING THIS ISSUE.
PS. I am new to the JBoss and JMX Agent .
Bu Bye -
5. Re: Monitor MBean from remote location
adrian.brock Jul 19, 2002 7:03 PM (in response to krasheed)Try this.
I'm no expert on the connector/adapter stuff.
import javax.management.ObjectName;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.Notification;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.naming.Context;
import org.jboss.jmx.connector.RemoteMBeanServer;
import org.jboss.jmx.connector.rmi.RMIConnectorImpl;
public class JMSAgent
implements NotificationListener
{
// The connection to the remote server
private static RMIConnectorImpl server = null;
// The string monitor
private static ObjectName monitorName = null;
public static void main(String[] args)
throws Exception
{
System.out.println("Setting naming context");
System.setProperty(Context.PROVIDER_URL,"jnp://zealous:1099");
System.setProperty(Context.INITIAL_CONTEXT_FACTORY ,"org.jnp.interfaces.NamingContextFactory");
System.setProperty(Context.URL_PKG_PREFIXES ,"org.jboss.naming:org.jnp.interfaces");
System.out.println("Creating an RMI connector");
server = new RMIConnectorImpl(RMIConnectorImpl.NOTIFICATION_TYPE_RMI,
null, "zealous");
System.out.println("Creating the string monitor");
monitorName = new ObjectName("test:service=StringMonitor");
server.createMBean("javax.management.monitor.StringMonitor", monitorName);
System.out.println("Configuring the string monitor");
ObjectName mbeanObjName = new ObjectName("jboss.mq:service=JMSProviderLoader,name=JBossMQProvider");
AttributeList attributes = new AttributeList();
attributes.add(new Attribute("ObservedObject", mbeanObjName));
attributes.add(new Attribute("ObservedAttribute", "StateString"));
attributes.add(new Attribute("StringToCompare", "Stopped"));
attributes.add(new Attribute("NotifyMatch", new Boolean(true)));
attributes.add(new Attribute("GranularityPeriod", new Long(10000)));
server.setAttributes(monitorName, attributes);
server.invoke(monitorName, "start", new Object[0], new String[0]);
System.out.println("Starting to listen....");
server.addNotificationListener(monitorName, new JMSAgent(), null, null);
}
// This is invoked when some idiot stops the mbean
public void handleNotification(Notification notification , Object HandBackObj)
{
System.out.println("Notification occured ......");
}
}
The main changes are:
Using the connector instead of the adaptor.
The monitor has to be registered in an MBeanServer that
can access the MBean being monitored.
Bugs:
The monitor and notification listener are not
removed if you stop the program.
Regards,
Adrian -
6. Re: Monitor MBean from remote location
krasheed Jul 20, 2002 11:21 AM (in response to krasheed)After executing this code; I got this error;
java.lang.NoClassDefFoundError: org/jboss/jmx/connector/notification/ClientNotificationListener
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
I have added jmx-rmi-connector-client.jar file which has ClientNotificationListener class and restarted the server but the error is still there.
What you think the reason of this error?
Bu Bye -
7. Re: Monitor MBean from remote location
krasheed Jul 22, 2002 2:26 AM (in response to krasheed)I have added required files to the Cient Classpath and this error has been overcame.
This is the output of the program execution . Program control doesn't enter handleNotification() even if I changes the StateString value from Started to Stopped. What would be the reason?
Please help me.....as did before.
Setting Naming Context
Creating RMI Connector
RMIClientConnectorImp.start(), got Naming Context: javax.naming.InitialContext@360be0, environment: {java.naming.provider.url=202.125.129.86:1099, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces}, name in namespace:
RMIClientConnectorImpl.start(), got remote connector: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl_Stub[RemoteStub [ref: [endpoint:[202.125.129.86:1485](remote),objID:[4b6009:ef30955971:-8000, 3]]]]
Creating String monitor
Configurng string Monitor
Starting to listen ........ -
8. Re: Monitor MBean from remote location
krasheed Jul 22, 2002 2:43 AM (in response to krasheed)Hi,
I have added required classes in Client's CLASSPATH and this error overcam.e
After executing this code, I m getting an strange type of error;
Setting Naming Context
Creating RMI Connector
RMIClientConnectorImp.start(), got Naming Context: javax.naming.InitialContext@360be0, environment: {java.naming.provider.url=202.125.129.86:1099, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces}, name in namespace:
RMIClientConnectorImpl.start(), got remote connector: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl_Stub[RemoteStub [ref: [endpoint:[202.125.129.86:1485](remote),objID:[4b6009:ef30955971:-8000, 3]]]]
Creating String monitor
Configurng string Monitor
Starting to listen ........
What might be the cause of this error?
I reckon I need to add some more classes to my classpath but which classes......Please Help me.
Thanx
Bu Bye -
9. Re: Monitor MBean from remote location
dhulley Sep 23, 2002 9:22 AM (in response to krasheed)Hi,
I might just be a humble mortal, but there doesn't seem to be any error message. The RMI stub has been brought into action and the calls are being executed according to plan.