我想使用 EJB3 规则会话从 Java 独立客户端在 Rule Execution Server 上执行规则。
public class TestGameExecute {
public static void main(String[] args) {
Map<String,Object> inputParameters = new HashMap<String, Object>();
Map<String,Object> resMap = null;
IlrEJB3SessionFactory ejbSF;
IlrStatelessSession rs;
Game game = new Game(10,3);
inputParameters.put("GAME", game);
Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put("java.naming.provider.url", "corbaloc:iiop:********");
jndiProperties.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
jndiProperties.put("java.naming.security.principal", "username");
jndiProperties.put("java.naming.security.credentials", "password");
try {
ejbSF = new IlrEJB3SessionFactory(jndiProperties);
ejbSF.setRemote(true);
ejbSF.setStatelessRemoteJndiName("ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");
rs = ejbSF.createStatelessSession();
IlrSessionRequest request = ejbSF.createRequest();
request.setRulesetPath(new IlrPath("/GAMLCDDRuleAppPhaseII/SiorkCDDRuleProject_PhaseII"));
request.setInputParameters(inputParameters);
request.setForceUptodate(true);
request.setTraceEnabled(true);
request.getTraceFilter().setInfoAllFilters(true);
IlrSessionResponse response = rs.execute(request);
resMap = response.getOutputParameters();
Game retGame =(Game)resMap.get("GAME");
System.out.println(retGame.getWinner());
} catch (IlrSessionCreationException e) {
e.printStackTrace();
} catch (IlrSessionException e) {
e.printStackTrace();
}
}
}
我在下面收到此错误:
线程“P = 421238:O = 0:CT”中的异常java.rmi.MarshalException:CORBA MARSHAL 0x4942f896否;嵌套异常是: org.omg.CORBA.MARSHAL: SERVER (id=614476eb, host=gamlwm000t01.esunbank.com.tw) TRACE START: org.omg.CORBA.MARSHAL: 无法从底层网桥读取值:无法读取来自底层桥的值:ClassNotFoundException com.siork.cdd.Game vmcid:IBM 次要代码:896 已完成:com.ibm.rmi.iiop.CDRReader.read_value(CDRReader.java:1649) 在 com.ibm.rmi.iiop .CDRReader.read_abstract_interface(CDRReader.java:1606) at com.ibm.rmi.iiop.CDRReader.read_abstract_interface(CDRReader.java:1591) at ilog.rules.res.session.impl.ejb3._EJSRemote0SLIlrStatelessSessionEJB3_fdcc75a4_Tie.execute(_EJSRemote0SLIlrStatelessSessionEJB3_fdcc75a4_Tie.java :100) 在 ilog.rules.res。
我已经在互联网上搜索了关于这个任务的解决方案
游戏.java
package com.siork.cdd;
import java.io.Serializable;
import ilog.rules.bom.annotations.BusinessName;
public class Game implements Serializable {
private static final long serialVersionUID = 1L;
public static String GAME = "GAME";
private int banker_point;
private int player_point;
private String winner;
public Game() {}
public Game(@BusinessName("BANKER") int banker_point,
@BusinessName("PLAYER") int player_point) {
this.banker_point = banker_point;
this.player_point = player_point;
}
public int getBanker_point() {
return banker_point;
}
public void setBanker_point(int banker_point) {
this.banker_point = banker_point;
}
public int getPlayer_point() {
return player_point;
}
public void setPlayer_point(int player_point) {
this.player_point = player_point;
}
public String getWinner() {
return winner;
}
public void setWinner(String winner) {
this.winner = winner;
}
}