我使用以下代码在ODM中创建规则触发列表,但是eclipse显示上面的编译错误。
package com.cper.brms.model.questions;
import ilog.rules.res.session.IlrSessionRequest;
import ilog.rules.res.session.IlrSessionResponse;
import ilog.rules.res.session.ruleset.IlrBusinessExecutionTrace;
import ilog.rules.res.session.ruleset.IlrExecutionTrace;
import ilog.rules.teamserver.auth.AuthenticationCredentials;
import ilog.rules.teamserver.model.IlrConnectException;
import ilog.rules.teamserver.model.IlrSession;
import ilog.rules.teamserver.model.IlrSessionFactory;
import java.util.List;
import java.util.Map;
public class RulesTrace<IlrStatelessSession>
{
IlrSessionFactory sessionFactory = new IlrJ2SESessionFactory();
IlrSessionRequest sessionRequest = sessionFactory.createRequest();
String rulesetPath = "/miniloanruleapp/miniloanrules";
}
sessionRequest.setRulesetPath(IlrPath.parsePath(rulesetPath));
sessionRequest.setTraceEnabled(true);
sessionRequest.getTraceFilter().setInfoAllFilters(true);
Map<String,Object> inputParameters = sessionRequest.getInputParameters();
inputParameters.put("loan", loan);
inputParameters.put("borrower", borrower);
IlrStatelessSession session = sessionFactory.createStatelessSession();
IlrSessionResponse response = session.execute(sessionRequest);
IlrExecutionTrace sessionTrace = response.getRulesetExecutionTrace();
int rulesNumber = sessionTrace.getTotalRulesFired();
IlrBusinessExecutionTrace execResult = new IlrBusinessExecutionTrace(response.getRulesetExecutionTrace());
List<String> rulesFired = execResult.getRuleFiredBusinessNames();
loan = (Loan) response.getOutputParameters().get("loan");
}
我是否需要创建任何自定义代码来创建会话工厂,或者我是否缺少任何 jar?
你的项目中缺少jrules-res-execution.jar。添加它应该可以解决问题。
是导致错误的版本不匹配。我的日食中有JAVAEE,但上面的代码是JavaSE的。将代码更改为正确的版本。