Hi,

I have successfully registered a JMX RMI Connector with in a registry in an
app process, looked it up by service type, and queried it for available
MBeans in a management process. I have many app instances starting/stopping,
and a single management instance that needs to know when the applications
come up or down, and to obtain access to their MBeans when they do.

To get started, I have run an example lookup on the management process. Now
instead of a pull interface (client driven poll), I want, if possible a
registry driven push interface, registry will tell the management process as
service become available/unavailable.

First of all, I'd like to know, am I taking the right approach? Is the
ServiceRegistrar.notify(...) method capable of doing what I want it to do
wrt a push driven interface between the registry and the management process?
There's not much documentation around so its hard to know. I was expecting a
remote call-back from the registry every time a matching service changes its
registration.

If I can't get it to work, I'll just fall back to a periodic polling
mechansim.

See below for the gruesome details, and many thanks for any help you are
able to give me.

Rupert

=====================================

Here's some code:

public class MBeanJiniListener extends StartStopLifecycleBase implements
RemoteEventListener, Serializable
{
...
    private void startListeningForJMXConnectors() throws IOException,
ClassNotFoundException
    {
        ServiceRegistrar registrar =
JiniUtils.getRegistrar(jiniRegistryURL);

        log.fine("registrar is: " + registrar);

        jmxConnections = new HashMap<JMXConnector, MBeanServerConnection>();

        Class[] classes = new Class[] { JMXConnector.class };
        Entry[] serviceAttrs =
            new Entry[] { new
com.sun.jini.lookup.entry.BasicServiceType(JMX_CONNECTOR_SERVICE_NAME) };

        ServiceTemplate template = new ServiceTemplate(null, classes,
serviceAttrs);

        eventRegistration =
            registrar.notify(template,
ServiceRegistrar.TRANSITION_MATCH_NOMATCH, this, null,
                Long.MAX_VALUE);
    }
}

This fails with a ClassNotFoundException on this line:

        eventRegistration =
            registrar.notify(template,
ServiceRegistrar.TRANSITION_MATCH_NOMATCH, this, null,
                Long.MAX_VALUE)

...
Caused by: java.lang.ClassNotFoundException:
com.rapidaddition.fix.management.jini.MBeanJiniListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at
net.jini.loader.pref.PreferredClassLoader.loadClass(PreferredClassLoader.java:922)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at
net.jini.loader.pref.PreferredClassProvider.loadClass(PreferredClassProvider.java:613)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:264)
at
sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:214)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1592)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:307)
... 9 more

I am using 'httpd.sh' and 'jrmp-reggie.sh' scripts from the hello example,
bundled with Apache River 2.1.1. Both have been modified to include all my
project .jars. That is:

'config/start-reggie.config'

...
    private static codebase =
        ConfigUtil.concat(
                          new Object[] {
                              "http://";, ConfigUtil.getHostName(),
":8080/reggie-dl.jar",
                              " ",
                              "http://";, ConfigUtil.getHostName(),
":8080/jsk-dl.jar",
                              " ",
                              "http://";, ConfigUtil.getHostName(),
":8080/genzero-mgt-1.2-beta2-SNAPSHOT.jar",
                              " ",
                              "http://";, ConfigUtil.getHostName(),
":8080/genzero-1.2-beta2-SNAPSHOT.jar",
                              " ",
                              "http://";, ConfigUtil.getHostName(),
":8080/genzero-api-1.2-beta2-SNAPSHOT.jar",
                              " ",
                              "http://";, ConfigUtil.getHostName(),
":8080/samples-1.2-beta2-SNAPSHOT.jar"
                          } );
...

and 'scripts/httpd.sh'

...
java -jar ../../../../../../../lib/classserver.jar -port 8080 -dir
lib:../../../../../../../lib-dl:/home/rupert/rapid/genzero/genzero-trunk/genzero-api/target:/home/rupert/rapid/genzero/genzero-trunk/genzero/target:/home/rupert/rapid/genzero/genzero-trunk/samples/target:/home/rupert/rapid/genzero/genzero-trunk/genzero-mgt/target
$*

Reply via email to