restcommmobicentsjain-slee

Sbb does not start on Mobicents JBoss 2.7.0


I am using mobicents-jainslee-2.7.0.FINAL-jboss-5.1.0.GA, and I try to deploy simple onTimerEvent Service. JBoss detects all components correctly but there is no logs in console when I click activate. In the other hand onStartedEventSbb works good.

Why this Service and Sbb are not run by server?

I have one TimerSbb.java:

public class TimerSbb implements Sbb {
    private Tracer tracer;
    private SbbContext sbbContext;
    private TimerFacility timerFacility;
    private NullActivityContextInterfaceFactory nullActivityContextFactory;
    private NullActivityFactory nullActivityFactory;

    private final int TIMER_PERIOD_IN_MILISECONDS = 500;

    public void onTimerEvent(TimerEvent timerEvent, ActivityContextInterface activityContextInterface) {
        tracer.info("onTimerEvent");
    }

    public void setSbbContext(SbbContext context) {
        this.sbbContext = context;
        tracer = this.sbbContext.getTracer(getClass().getSimpleName());
        tracer.info("setSbbContext");
        try {
            Context initialContext = new InitialContext();
            timerFacility = (TimerFacility) initialContext.lookup(TimerFacility.JNDI_NAME);
            nullActivityContextFactory = (NullActivityContextInterfaceFactory) initialContext.lookup(NullActivityContextInterfaceFactory.JNDI_NAME);
            nullActivityFactory = (NullActivityFactory) initialContext.lookup(NullActivityFactory.JNDI_NAME);
        } catch (NamingException e) {
            tracer.warning("NamingException", e);
        }
        setupTimer();
    }

    private void setupTimer() {
        ActivityContextInterface nullActivityContext = nullActivityContextFactory.getActivityContextInterface(nullActivityFactory.createNullActivity());
        timerFacility.setTimer(nullActivityContext, null, System.currentTimeMillis(), TIMER_PERIOD_IN_MILISECONDS, 0, new TimerOptions());
        nullActivityContext.attach(sbbContext.getSbbLocalObject());
        tracer.info("Timer set up. Period = " + TIMER_PERIOD_IN_MILISECONDS + " ms");
    }

    public void unsetSbbContext() {
        tracer.info("unsetSbbContext");
    }

    public void sbbCreate() throws CreateException {
        tracer.info("sbbCreate");
    }

    public void sbbPostCreate() throws CreateException {
        tracer.info("sbbPostCreate");
    }

    public void sbbActivate() {
        tracer.info("sbbActivate");
    }

    public void sbbPassivate() {
        tracer.info("sbbPassivate");
    }

    public void sbbLoad() {
        tracer.info("sbbLoad");
    }

    public void sbbStore() {
        tracer.info("sbbStore");
    }

    public void sbbRemove() {
        tracer.info("sbbRemove");
    }

    public void sbbExceptionThrown(Exception e, Object o, ActivityContextInterface activityContextInterface) {
        tracer.info("sbbExceptionThrown");
    }

    public void sbbRolledBack(RolledBackContext rolledBackContext) {
        tracer.info("sbbRolledBack");
    }

}

sbb-jar.xml:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sbb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE SBB 1.1//EN"
        "http://java.sun.com/dtd/slee-sbb-jar_1_1.dtd">

<sbb-jar>
    <sbb>
        <sbb-name>TimerSbb</sbb-name>
        <sbb-vendor>com.example</sbb-vendor>
        <sbb-version>1.0</sbb-version>
        <sbb-classes>
            <sbb-abstract-class>
                <sbb-abstract-class-name>
                    com.example.slee.TimerSbb
                </sbb-abstract-class-name>
            </sbb-abstract-class>
        </sbb-classes>

        <event event-direction="Receive">
            <event-name>TimerEvent</event-name>
            <event-type-ref>
                <event-type-name>javax.slee.facilities.TimerEvent</event-type-name>
                <event-type-vendor>javax.slee</event-type-vendor>
                <event-type-version>1.0</event-type-version>
            </event-type-ref>
        </event>

    </sbb>
</sbb-jar>        

timer-service.xml:

<service-xml>
<service>
    <service-name>Timer Service</service-name>
    <service-vendor>com.example</service-vendor>
    <service-version>1.0</service-version>
    <root-sbb>
        <sbb-name>TimerSbb</sbb-name>
        <sbb-vendor>com.example</sbb-vendor>
        <sbb-version>1.0</sbb-version>
    </root-sbb>
    <default-priority>0</default-priority>
</service>

deployable-unit.xml:

<deployable-unit>
    <jar>lib/timer-sbb-1.0-SNAPSHOT.jar</jar>
    <service-xml>timer-service.xml</service-xml>
</deployable-unit>

I am building jar with Maven: Jar structure is:

example.jar:

 - lib/timer-sbb-1.0-SNAPSHOT.jar
 - timer-service.xml
 - META-INF/deployable-unit.xml

timer-sbb-1.0-SNAPSHOT.jar:
 - com.example.slee.TimerSbb
 - META-INF/sbb-jar.xml

Solution

  • The problem was with creating timer by TimerFacility in setSbbContext method. It was probably too early and if I moved method setupTimer() to onServiceStartedEvent() it works.