我试图将多个对象传递给没有部署Glassfish 3.1.1的EJB远程接口。无论第一个对象是什么都会好转,第二个对象总是为空。是由于rmi-iiop的规格还是属性设置?
这是我的属性设置:
final Properties props = new Properties();
props.setProperty(InitialContext.STATE_FACTORIES,
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.192");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
// props.setProperty("com.sun.appserv.iiop.orbconnections","5");
// Increase ORB Response Timeout to 5 min instead of 30 min:
// props.setProperty("com.sun.corba.ee.transport.ORBTCPTimeouts",
// "500:90000:20");
props.setProperty(
"com.sun.corba.ee.transport.ORBWaitForResponseTimeout",
"300000");
try {
InitialContext ic=new InitialContext(props);
TestRemote remote=(TestRemote) ic.lookup("java:global/com.capmtech_test.ear-ear_ear_1.0-SNAPSHOT/test.ear-ejb-1.0-SNAPSHOT/Test!com.capmtech.TestRemote");
Person p = new Person();
p.setName("Smith");
Phone m = new Phone();
remote.test(p, m);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这是无状态EJB:
@Stateless
public class Test implements TestRemote {
@EJB
private PersonFacadeLocal personFacade;
@Override
public void test(Person person, Phone mobile) {
Person p = person;
p.setMobile(mobile);
personFacade.create(p);
}
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
}
在这种情况下,移动设备将始终为空,如果我交换了空缺,则人为空!如果IP设置为localhost,一切都会正常工作。
请帮忙
答案 0 :(得分:0)
替换以下行:
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.192");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
使用:
props.setProperty(Context.PROVIDER_URL,"iiop://192.168.1.192:3700");
答案 1 :(得分:0)
这是假设您在同一台计算机上运行glassfish服务器和独立客户端。我能够重现这方面的问题。虽然这不是您的问题,但您可能会得到相同更改的结果。我在Windows Vista上运行GF 3.1。我的windows \ system32 \ drivers \ etc \ hosts文件包含以下行:
10.99.0.199 pc-2017.pgx.local
127.0.0.1 localhost pc-2017.pgx.local
当我的客户端软件连接时:
props.put("org.omg.CORBA.ORBInitialHost", "localhost");
我收到错误:
Exception in thread "main" javax.ejb.EJBException: java.rmi.RemoteException: CORBA INTERNAL 1330446421 No; nested exception is:
org.omg.CORBA.INTERNAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.INTERNAL: WARNING: IOP00710085: A reflective tie got an error while invoking method saveMonkey on class com.pts.monkey._MonkeySessionRemote_Remote
vmcid: OMG minor code: 85 completed: No
但是如果我改变客户端连接:
props.put("org.omg.CORBA.ORBInitialHost", "pc-2017.pgx.local");
它可以正常工作。