[jboss-user] [EJB 3.0] - JBoss 4.2.2 and TimerService null pointer exception

kyle.bober do-not-reply at jboss.com
Fri Aug 15 08:53:56 EDT 2008


I have a Stateless session bean that is also a WebService. When I attempt to inject a TimerService and create a new timer Instance the TimerService is always returned as null. It seems the TimerService is never injected. I also attempted injecting the SessionContext as well using @Resource and obtaining the TimerService via the SessionContext but the SessionContext is also null. Here is the code:

package somepackage;

import java.rmi.RemoteException;
import java.util.Date;
import java.util.Set;

import javax.annotation.Resource;
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.Service;

/**
* Class which contains each of the services calls used by the client side.
* @author pcrane
*
*/
@WebService
@Stateless
@Remote(IMemberService.class)
@RemoteBinding(jndiBinding="MemberService/remote")
public class MemberService implements IMemberService
{
// @Resource
// public SessionContext theSessionContext;

@Resource
public TimerService theTimerService;

@Timeout
public void deleteUnauthorizedMembers(Timer aTimer) throws RemoteException
{
Long memberID = (Long) aTimer.getInfo();
MemberServiceImpl.deleteMember(memberID);
}

/* (non-Javadoc)
* @see com.thesearchagency.transformer.services.member.IMemberService#memberServiceUpdateAccount()
*/
@WebMethod
@WebResult(name = "memberID")
public String memberServicePersistMember(@WebParam(name="memberProfile") MemberServiceUser aUser) throws RemoteException
{
TimerService ts = theSessionContext.getTimerService();
ts.createTimer(timerExecutionDate, aUser.getMemberId());
return MemberServiceImpl.memberServicePersistMember(aUser);
}
}



package somepackage;

import java.rmi.RemoteException;
import java.util.Date;
import java.util.Set;

public interface IMemberService
{
String memberServicePersistMember(MemberServiceUser aUser) throws RemoteException;
}

Please help! I ahve been racking my brain on this for a few hours now and Timers should be fairly easy in EJB3.0!

Thanks,
Kyle

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170743#4170743

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170743



More information about the jboss-user mailing list