ILOG Jrules规则集EJB怎么调用
我的代码如下:public class JruleInvokerTest {
public static void main(String[] args) {
try {
IlrStatelessSession stateLessSession;
IlrEJB3SessionFactory factory = new IlrEJB3SessionFactory();
factory.setStatelessRemoteJndiName("ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");
factory.setRemote(true);
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "corbaloc:iiop:127.0.0.1:2809");
InitialContext ic = new InitialContext(env);
Object lookupResult = ic.lookup("ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");
//Object lookupResult = ic.lookup("ejb/IlrStatelessRuleSessionEJB");
stateLessSession = (IlrStatelessSession) PortableRemoteObject.narrow(lookupResult, IlrStatelessSession.class);
IlrSessionResponse sessionResponse = null;
IlrSessionRequest sessionRequest = null;
sessionRequest = factory.createRequest();
sessionRequest.setRulesetPath(IlrPath.parsePath("/orderDecisionruleapp/OrderDecisionRules"));
OrderDecision od = new OrderDecision("IBM", 100.00, 20.00);
sessionRequest.setInputParameter("orderDecision", od);
sessionResponse = stateLessSession.execute(sessionRequest);
Map<String, Object> map = sessionResponse.getOutputParameters();
Object obj = map.get("orderDecision");
if (obj != null) {
OrderDecision orderDecision = (OrderDecision) obj;
Boolean canContinue = orderDecision.getCanContinue();
if (canContinue != false) {
System.out.println("SUCCESS");
} else {
System.out.println("FAILD");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Ilog Jrules Invoke Exception:"
+ e.getMessage(), e);
}
}
}
报的错误:
WARNING: jndiNamingException
com.ibm.ws.naming.util.InvalidObjectException: Some object reference in the name "ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote" relative to the context "yangshiyun-PCNode01Cell/nodes/yangshiyun-PCNode01/servers/server1" is invalid. Some possible causes include a context binding in the name which refers to a destroyed context, or an object binding which contains an invalid EJBHome reference. [Root exception is org.omg.CORBA.INV_OBJREF:
>> SERVER (id=4773e3aa, host=yangshiyun-PC) TRACE START:
>> org.omg.CORBA.INV_OBJREF: Could not resolve IOR string. vmcid: 0x0 minor code: 0 completed: No
>> at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.resolveUnresolvedBinding(WsnOptimizedNamingImpl.java:1995)
>> at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.resolve_binding(WsnOptimizedNamingImpl.java:1675)
>> at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:580)
>> at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:2163)
>> at com.ibm.WsnOptimizedNaming._NamingContextImplBase._invoke(_NamingContextImplBase.java:286)
>> at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:622)
>> at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:475)
>> at com.ibm.rmi.iiop.ORB.process(ORB.java:504)
>> at com.ibm.CORBA.iiop.ORB.process(ORB.java:1571)
>> at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2771)
>> at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2640)
>> at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:63)
>> at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
>> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
>> SERVER (id=4773e3aa, host=yangshiyun-PC) TRACE END.
vmcid: 0x0 minor code: 0 completed: No]
at com.ibm.ws.naming.jndicos.CNContextImpl.mapINV_OBJREF(CNContextImpl.java:4391)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1807)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1748)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1499)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:636)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:431)
at com.wcs.chengdu.ilog.clinent.JruleInvokerTest.main(JruleInvokerTest.java:30)
请各位大侠指教! --------------------编程问答--------------------
这一句中,RulesetPath的格式修改一下:
/orderDecisionruleapp/ruleApp版本号/OrderDecisionRules
例如:
/orderDecisionruleapp/1.0/OrderDecisionRules --------------------编程问答-------------------- sessionRequest.setInputParameter("orderDecision", od);
修改为:
sessionRequest.getInputParameter.put("orderDecision", od); --------------------编程问答-------------------- 向两位规则引擎大拿学习
补充:Java , Java EE