Hi,

I've tried to add new daemon service, following this post. Somehow, ONMS
cannot start my service class. 

Here is the MBean interface:

import org.opennms.netmgt.daemon.BaseOnmsMBean;

public interface TestMBean extends BaseOnmsMBean {

}

jmx Testd.java

package org.nms.service.test.jmx;

import org.opennms.netmgt.daemon.AbstractServiceDaemon;


public class Testd extends AbstractServiceDaemon implements TestMBean{
    /**
     * Logging category for log4j
     */
    private static String LOG4J_CATEGORY = "OpenNMS.Testd";

    /**
     * <p>Constructor for Testd.</p>
     */
    public Testd() {
        super(LOG4J_CATEGORY);
    }

    /**
     * <p>onInit</p>
     */
    protected void onInit() {
        Testd().init();
    }

    /**
     * @return Testd instance
     */
        private org.nms.service.test.Testd Testd() {
            return org.nms.service.test.Testd.getInstance();
    }

    /**
     * <p>onStart</p>
     */
    protected void onStart() {
        Testd().start();
    }

    /**
     * <p>onStop</p>
     */
    protected void onStop() {
        Testd().stop();
    }

    public int getStatus() {
        return Testd().getStatus();
    }
}


and service implementation Testd.java

package org.nms.service.test;

import org.opennms.netmgt.daemon.AbstractServiceDaemon;


public class Testdextends AbstractServiceDaemon {

        private static final Testd m_singleton = new Testd();
        
        public Testd() {
                super("OpenNMS.Testd");
        }

    public static Testd getInstance() {
        return m_singleton;
    }

        @Override
        protected void onInit() {
                // TODO Auto-generated method stub
                
        }    
    
    /**
     * <p>onStart</p>
     */
    protected void onStart() {
    }

    /**
     * <p>onStop</p>
     */
    protected void onStop() {
    }

    /**
     * <p>onPause</p>
     */
    protected void onPause() {
    }

    /**
     * <p>onResume</p>
     */
    protected void onResume() {
    }
}

service configuration:

  <service>
    <name>OpenNMS:Name=Testd</name>
    <class-name>org.nms.service.test.jmx.Testd</class-name>
    <invoke at="start" pass="0" method="init"/>
    <invoke at="start" pass="1" method="start"/>
    <invoke at="status" pass="0" method="status"/>
    <invoke at="stop" pass="0" method="stop"/>
  </service>

I didn't put real logic inside those functions yet. I want to make sure the
service can be started before I carry on my coding. Somehow, when I put my
jar file into lib folder and restart ONMS, I got the following exception:

An error occurred while attempting to start the "OpenNMS:Name=Testd
" service (class org.nms.service.test.jmx.Testd).
 Shutting down and exiting.
javax.management.NotCompliantMBeanException: org.nms.service.test.jmx.Testd
 does not implement DynamicMBean, neither f
ollows the Standard MBean conventions
(javax.management.NotCompliantMBeanExcepti
on: Class org.nms.service.test.jmx.Testd is not a
JMX compliant Standard MBean) nor the MXBean conventions
(javax.management.NotCo
mpliantMBeanException: org.nms.service.test.jmx.Testd: Class
org.nms.service.test.jmx.Testd is not a
 JMX compliant MXBean)

Can anyone tell me what is wrong with my code structure? Thx.

Regards
DJ

--
View this message in context: 
http://opennms.530661.n2.nabble.com/Trying-to-write-OpenNMS-daemon-event-handler-tp7253144p7388845.html
Sent from the OpenNMS - devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this 
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel

Reply via email to