RMIConnectorImpl problem
parisila Feb 27, 2004 6:16 PMI am trying to do a test application that creates a ServiceMBean and that I can connect to from a client application to read and invoke methods and as a listener. I am using JBoss 3.2.3.
I was successful connecting to the MBean Server with the RMIAdaptor to read info on the MBean and invoke methods.
I created a seperate application for the listener using the RMIConnectorImpl class. Here is the code:
import javax.management.ObjectName;
import javax.management.NotificationListener;
import javax.management.Notification;
import javax.naming.Context;
import org.jboss.jmx.connector.rmi.RMIConnectorImpl;
public class JmxListener
implements NotificationListener {
public static void main(String[] args) throws Exception {
JmxListener jmxListener = new JmxListener();
jmxListener.runTest();
while (true) {
}
}
public void runTest() throws Exception {
System.out.println("Setting naming context");
System.setProperty(Context.PROVIDER_URL, "jnp://localhost: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");
RMIConnectorImpl server = new RMIConnectorImpl(RMIConnectorImpl.
NOTIFICATION_TYPE_RMI, null, "localhost");
if (server != null) {
ObjectName name = new ObjectName("JBossSar:service=JBossTestService");
System.out.println("Starting to listen....");
server.addNotificationListener(name, this, null, null);
}
}
public void handleNotification(Notification notification, Object HandBackObj) {
System.out.println("Notification occured ......");
}
}
I am getting an error
javax.naming.NameNotFoundException: jmx:localhost:rmi not bound
when creating new RMIConnectorImpl
When I look in the Agent view there is no RMIConnector service only the RMIAdaptor service.
In my client application when I run the code to check if the RMIConnector is registered I get a false.
boolean rmiConnectorIsRegistered = server.isRegistered(new ObjectName(
"DefaultDomain:service=RMIConnector"));
Is the problem that I have to configure the RMIConnector and if so, how do I do that or is there some other problem? Thanks.