Global JNDI on JBoss with MBeans

I

iksrazal

Hi all,

I have a simple goal of invoking a session bean on app startup:

timer-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<server>
<classpath codebase="." archives="CallCentreWebServiceJAR.jar"/>
<mbean code="org.jboss.varia.scheduler.Scheduler"
name="CallCentreWeb:service=Scheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute
name="SchedulableClass">com.hostedtelecom.callcentreweb.util.TimerStart</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="SchedulePeriod">5000</attribute>
<attribute name="InitialRepetitions">-1</attribute>

<depends>jboss.j2ee:jndiName=ejb/TimerCallCentre,service=EJB</depends>
<depends>
<mbean code="javax.management.timer.Timer"
name="jboss:service=Timer"/>
</depends>
</mbean>
</server>


I probably do not need my first depends. My app is in the jar shown - I
don't have a war or access to ServletContext, etc.

I can get TimerStart to work via a static reference in the client login
when it occurs. Using the same code in the mbean, I get 'env not bound'
.. Here's my code:

Code:

public class TimerStart implements Schedulable {

private static final String JNDI_TIMER=
"java:comp/env/ejb/TimerCallCentre";

public void perform(Date now, long remainingRepetitions) {

ServiceLocator serviceLocator = ServiceLocator.getInstance();
TimerCallCentreHome timerCallCentreHome = (TimerCallCentreHome)
serviceLocator.getEJBHome(JNDI_T
IMER,TimerCallCentreHome.class);

}
}

I've tried ejb/TimerCallCentre" , java:ejb/TimerCallCentre" etc. My
ejb-name is:

<ejb-name>TimerCallCentreBean</ejb-name>

Please help,
iksrazal
 
I

iksrazal

In the interest of helpping others, this is how it turned out:

<?xml version="1.0" encoding="UTF-8"?>
<server>
<classpath codebase="." archives="CallCentreWebServiceJAR.jar"/>
<mbean code="org.jboss.varia.scheduler.Scheduler"
name="CallCentreWeb:service=Scheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute
name="SchedulableClass">com.hostedtelecom.callcentreweb.util.TimerStart</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="SchedulePeriod">5000</attribute>
<attribute name="InitialRepetitions">1</attribute>
<depends>
<mbean code="javax.management.timer.Timer"
name="jboss:service=Timer"/>
</depends>

<depends>jboss.j2ee:module=CallCentreWebServiceJAR.jar,service=EjbModule</depends>
</mbean>
</server>

Context ctx = new InitialContext();
Object result = ctx.lookup("ejb/TimerCallCentre");
TimerCallCentreHome timerCallCentreHome = (TimerCallCentreHome)
javax.rmi.PortableRemoteObject.narrow(result,
TimerCallCentreHome.class);

The trick was the ejb 'depends' - the bounded contexts are listed in
the jmx console,

HTH,
iksrazal
http://www.braziloutsource.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top