2

我已经定义了一个 EJB 类 - GetTransactionDataForMercury。请在下面找到示例代码:

@Stateless
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public class GetTransactionDataForMercury {

@EJB
private BusinessLocal business;

private Long historyId = null;

public GetTransactionDataForMercury(){
    super();
}

public void getHistoryForMercury() {
    try {
        historyId = getConfigHistoryId("QueryDslConfig");

    } catch (Exception exception) {
        notifier.error("Error Occured  -- > "+exception);
    }

}

public Long getConfigHistoryId(String requestType){
    notifier.info(" Processing QueryDslConfig " );
    Long historyId = null;
    BaseEntity entity = null;
    Long transactionStartTime = null;
    Long transactionEndTime = null;
    ConfigEntity configEntities[] = null;
    Query query = null;

    try{
        transactionStartTime = System.currentTimeMillis();
        notifier.info(" Going to Query  " );
        notifier.info("Business object created : " + business);
        List<BaseEntity> entities = business.query(new QueryFactory(requestType).create());
        notifier.info(" No. of entities fetched  " + entities.size());

        historyId = Long.parseLong(configEntities[0].getConfigId());
            notifier.info("History Id stored : " + historyId);

    }catch(Exception exception){
        transactionEndTime = System.currentTimeMillis();
        notifier.error("Error Occured  -- > "+exception.getMessage());
    }
    return historyId;
}

BusinessLocal 是由 EJB 类 - BusinessSLSB 实现的 EJB 接口。我在以下行面临一个空错误:

notifier.info("Business object created : " + business);

我需要知道为什么 EJB 对象为空?创建 EJB 类 - GetTransactionDataForMercury 有什么问题吗?

请建议!

4

1 回答 1

0

看起来您的 SLSB 没有实现任何 @Local 或 @Remote 接口。因此,它可能没有被 JBoss 正确初始化,也没有注入它的依赖项。

于 2013-03-26T10:27:42.893 回答