EJB @scheduler方法调用失败

时间:2016-09-05 14:09:04

标签: java java-ee jboss ejb scheduler

我正在尝试使用@scheduler但是它无法调用我的EJB2对象。是因为@scheduler在EJB 3.1中,我试图调用EJB2,因为它不支持它?还是缺少一些东西:

@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());

               }
            }

        }

当它到达下面的行时会抛出异常:

  

公司公司=   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;
}

抛出以下异常:

    [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)

上面的代码在整个应用程序的调度程序之外工作正常,所以我确信它与@Scheduler有什么关系到底是什么不确定。任何帮助表示赞赏。

0 个答案:

没有答案