Я пишу сервер Iiop, и я столкнулся со следующей ошибкой при попытке запустить его:
Exception in thread "main" javax.naming.ConfigurationException: Problem with PortableRemoteObject.toStub(); object not exported or stub not found [Root exception is java.rmi.NoSuchObjectException: object not exported]
at com.sun.jndi.toolkit.corba.CorbaUtils.remoteToCorba(CorbaUtils.java:105)
at com.sun.jndi.cosnaming.RemoteToCorba.getStateToBind(RemoteToCorba.java:79)
at javax.naming.spi.NamingManager.getStateToBind(NamingManager.java:870)
at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:600)
at com.sun.jndi.cosnaming.CNCtx.rebind(CNCtx.java:713)
at com.sun.jndi.cosnaming.CNCtx.rebind(CNCtx.java:730)
at javax.naming.InitialContext.rebind(InitialContext.java:433)
at ExecRmiIiopServ.<init>(ExecRmiIiopServ.java:13)
at ExecRmiIiopServ.main(ExecRmiIiopServ.java:20)
Caused by: java.rmi.NoSuchObjectException: object not exported
at sun.rmi.transport.ObjectTable.getStub(ObjectTable.java:124)
at java.rmi.server.RemoteObject.toStub(RemoteObject.java:106)
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.toStub(PortableRemoteObject.java:156)
at javax.rmi.PortableRemoteObject.toStub(PortableRemoteObject.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.jndi.toolkit.corba.CorbaUtils.remoteToCorba(CorbaUtils.java:99)
... 8 more
Из того, что я читал об этой ошибке, мне нужны строго типизированные объявления объекта, чтобы сборщик мусора не отбрасывал его, поэтому я попытался добавить объект функций, который делает именно это, но все равно ошибка сохраняется, как при обычном запуске, так и с точкой останова, ошибка запускается в строке ctx.rebind.
public class ExecRmiIiopServ {
public ExecRmiIiopServ(String host, String port, String nume) throws Exception {
Runtime.getRuntime().exec("cmd /c start orbd -ORBInitialPort 1050");
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
props.setProperty("java.naming.provider.url", "iiop://" + host + ":" + port);
ExecRmiInte functions = new ExecRmiImpl();
Context ctx = new InitialContext(props);
ctx.rebind(nume, functions);
System.out.println("Java RMI IIOP waiting: " + host + ":" + port + "/" + nume);
}
public static void main(String args[]) throws Exception {
if (args.length > 2)
new ExecRmiIiopServ(args[0], args[1], args[2]);
else
new ExecRmiIiopServ("localhost", "1050", "ExecIiop");
}
}
Класс ExecRmiImpl () пока что таков:
public class ExecRmiImpl implements ExecRmiInte {
public ExecRmiImpl() { }
}
Что я делаю не так?