我已经定义了一个 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 有什么问题吗?
请建议!