首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ejb连接到JRules

使用ejb连接到JRules
EN

Stack Overflow用户
提问于 2015-03-02 06:26:13
回答 1查看 346关注 0票数 0

我试图从部署在WAS (8.5)实例上的EAR调用RES服务器(v7.1)。我能够从独立的程序中调用规则服务器,并且它的工作没有任何问题。

但是,我的主要问题是远程调用部署在RES服务器上的EJB,从另一个部署在其他is实例上的EAR调用EJB。在这种情况下,我们无法远程查找EJB。

按照下面的线程,我们应该绕过Java,应该使用EJB3 IlrSessionFactory API直接查找规则会话。

http://www-01.ibm.com/support/docview.wss?uid=swg21586621

IBM的建议是使用标准的java来查找ejb,或者升级到RuleServer7.5(最新的8.x)。

代码片段

代码语言:javascript
复制
// Initialization
               Map<String, Object> outputParms = null;


               IlrStatelessSession session=null;
                IlrSessionResponse response=null;  

               // IlrSessionFactory factory = getFactory();

               try {

                         sessionFactory = JRulesInvoker.getFactory();

                         Hashtable<String, String> env = new Hashtable<String, String>();
                         env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
                         env.put(Context.PROVIDER_URL,"corbaloc:iiop:localhost:28004");
                         Context ctx = new InitialContext(env);

                         Object lookupResult = ctx.lookup("ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");

                         PortableRemoteObject aPortableRemoteObject = new PortableRemoteObject();
                         session = (IlrStatelessSession) aPortableRemoteObject.narrow(lookupResult, IlrStatelessSession.class);

                         IlrPath path = new IlrPath(ruleApp, ruleSet);



                         IlrSessionRequest request = sessionFactory.createRequest();

                         request.setRulesetPath(path);

                         request.setInputParameters(inputParms);


                         request.getTraceFilter().setInfoTotalRulesFired(true);
                         request.getTraceFilter().setInfoExecutionEvents(true); 
                         request.setTraceEnabled(true);

                         // session = sessionFactory.createStatelessSession();
                         System.out.println("created session " + IlrJNDIConstants.STATELESS_SESSION_EJB3_NAME);

                         response = session.execute(request);

                         System.out.println(response.getRulesetExecutionTrace().getTotalRulesFired() + " rule(s) fired.");
                         System.out.println("Execution output=" + response.getRulesetExecutionOutput());


                         // Return the result(s)
                         outputParms = response.getOutputParameters();

                         if (logger.isEnabledFor(Level.DEBUG)) {
                                  if (response.getRulesetExecutionOutput() != null) {
                                            logger.debug("RuleSet execution output: \n" + response.getRulesetExecutionOutput());
                                  }
                         }

               }catch (IlrSessionCreationException cx) {
                         if (logger.isEnabledFor(Level.ERROR)) {
                                  logger.error(cx.getMessage(), cx);
                         }        
               } catch (IlrSessionException e) {
                         if (logger.isEnabledFor(Level.ERROR)) {
                                  logger.error(e.getMessage(), e);
                         }
               } catch (NamingException e) {
                         if (logger.isEnabledFor(Level.ERROR)) {
                                  logger.error(e.getMessage(), e);
                         }
               } 

误差

代码语言:javascript
复制
Context: idewas/nodes/ide/servers/server1, name: ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote: First component in name ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote not found.
javax.naming.NameNotFoundException: Context: idewas/nodes/ide/servers/server1, name: ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote: First component in name ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at com.ibm.ws.naming.jndicos.CNContextImpl.mapNotFoundException(CNContextImpl.java:4563)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1821)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1776)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1433)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:615)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
at javax.naming.InitialContext.lookup(InitialContext.java:436)
EN

回答 1

Stack Overflow用户

发布于 2015-03-04 09:48:14

签入RES服务器的SystemOut.log --EJB的绑定名称是什么,因为这里似乎没有ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote。此外,如果同一主机上有两个服务器,名称相同,例如server1,则可能存在可互操作问题,需要将JVM属性com.ibm.websphere.orb.uniqueServerName设置为true。有关详细信息,请参阅下面的页面应用程序访问问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28803805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档