1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[JBoss] EJB @scheduler method invocation failed

Discussão em 'StackOverflow' iniciado por Stack, Fevereiro 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to work with @scheduler however it is failed to call my EJB2 object. Is it because @scheduler is in EJB 3.1 and I am trying to call EJB2 therefor it do not support it?? or is there something missing:

    @Singleton
    public class BatchUserPermissionUpdater {

    Date now;
    @Inject
    private IUserCompanyPermission permission;
    @EJB
    private CompanyBusiness companyBusiness;

    @Schedule(minute="*/1",hour="*", persistent=false)
    public void execute() {
    now = new Date();
    Logger.instance().logInfo(this,"Executing scheduler. Time is :" + now);

    List<UserCompanyPermission> userList= permission.findAllUserCompanyPermission();

    if(userList!=null && !userList.isEmpty()){
    updateAccess(userList);
    }
    }

    public void updateAccess(List<UserCompanyPermission> userList) {

    for ( UserCompanyPermission list : userList) {
    Company company = companyBusiness.getCompanyBySID(list.getCompanyId());

    }
    }

    }


    When It reach to line below it throw Exception:


    Company company = companyBusiness.getCompanyBySID(list.getCompanyId());

    @Stateless
    public class CompanyFacadeImpl extends EntityServiceImpl<CompanyEntity, Long> implements CompanyBusiness {

    @EJB
    CompanyHome companyHome;

    @Override
    public Company getCompanyBySID(long id) throws RemoteException, FinderException {
    return companyHome.findByPrimaryKey(new SnapshotPK(id));
    }

    }


    CompanyHome :

    public interface CompanyHome extends EJBHome {
    public Company findByPrimaryKey(SnapshotPK pk) throws RemoteException, FinderException;
    }


    Following exception is thrown:

    [org.jboss.as.ejb3.invocation] (EJB default - 1) JBAS014134: EJB Invocation failed on component Company for method public abstract com.iumnordic.snapshot.remote.Company com.iumnordic.snapshot.home.CompanyHome.findByPrimaryKey(com.iumnordic.snapshot.util.SnapshotPK) throws java.rmi.RemoteException,javax.ejb.FinderException: javax.ejb.EJBAccessException: JBAS014502: Invocation on method: public abstract com.iumnordic.snapshot.remote.Company com.iumnordic.snapshot.home.CompanyHome.findByPrimaryKey(com.iumnordic.snapshot.util.SnapshotPK) throws java.rmi.RemoteException,javax.ejb.FinderException of bean: Company is not allowed
    at com.sun.proxy.$Proxy146.findByPrimaryKey(Unknown Source)
    at com.iumnordic.snapshotx.ejb.stateless.DefaultCompanyFacadeImpl.getCompanyBySID(DefaultCompanyFacadeImpl.java:222) [snapshot-ejb3-0.0.1-SNAPSHOT.jar:]
    com.iumnordic.snapshotx.ejb.business.CompanyBusiness$$$view75.getCompanyBySID(Unknown Source) [snapshot-ejb3-0.0.1-SNAPSHOT.jar:]
    at com.iumnordic.timertask.BatchUserPermissionUpdater.updateAccess(BatchUserPermissionUpdater.java:79)
    at com.iumnordic.timertask.BatchUserPermissionUpdater.execute(BatchUserPermissionUpdater.java:58)


    Code above is working fine outside the scheduler throughout in application so I am sure it has something to do with @Scheduler what exactly it is not sure.

    Continue reading...

Compartilhe esta Página