我想使用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();
}
}
}
我在下面收到此错误:
线程中的异常&#34; P = 421238:O = 0:CT&#34; 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) at com.ibm.rmi.iiop.CDRReader.read_abstract_interface(CDRReader.java:1606) 在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) at ilog.rules.res.session.impl.ejb3._EJSRemote0SLIlrStatelessSessionEJB3_fdcc75a4_Tie._invoke(EJSRemote0SLIlrStatelessSessionEJB3_fdcc75a4_Tie.java) at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:669) 在com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:523) 在com.ibm.rmi.iiop.ORB.process(ORB.java:523) 在com.ibm.CORBA.iiop.ORB.process(ORB.java:1575) 在com.ibm.rmi.iiop.Connection.doRequestWork(Connection.java:3039) 在com.ibm.rmi.iiop.Connection.doWork(Connection.java:2922) 在com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64) 在com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118) 在com.ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1815) SERVER(id = 614476eb,host = gamlwm000t01.esunbank.com.tw)TRACE END。
我在互联网上搜索关于此任务的搜索
Game.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;
}
}
答案 0 :(得分:0)
您的Java独立客户端“TestGameExecute”需要在其类路径上包含com.siork.cdd.Game,以便能够通过RMI解组此类的实例。
答案 1 :(得分:0)
这是一个JDK问题。 检查您的JDK版本,升级它,对我来说它应该是8.x