![](/img/trans.png)
[英]Weblogic JMX error IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
[英]org.omg.CORBA.ORBPackage.InvalidName: IDL:omg.org/CORBA/ORB/InvalidName:1.0
您好,我正在嘗試在 eclipse 上使用 CORBA 創建桌面應用程序。當我執行服務器 class main 時,我遇到了這個錯誤,盡管我已經導入了 corba 和 jcorb 的 API:
INFO Initialising ORB with ID:
INFO InterceptorManager started with 0 Server Interceptors, 0 Client Interceptors and 1 IOR Interceptors
INFO oid: 00 01 32 39 36 19 1F 2A 35 10 06 30 46 38 14 14 1B 48 4C 1B ..296..*5..0F8...HL.object is activated
INFO Using server ID (3169780447) for transient POA
org.omg.CORBA.ORBPackage.InvalidName: IDL:omg.org/CORBA/ORB/InvalidName:1.0
at org.jacorb.orb.ORB.resolve_initial_references(ORB.java:1608)
at main.SraCorbaServer.main(SraCorbaServer.java:50)
這是服務器 class 的主要代碼,如下所示:
package main;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextHelper;
public class SraCorbaServer {
public static void main(String[] args) {
try {
/ // Initialisation de l'ORB
ORB orb = ORB.init(args, null);
// Récupérer la référence du RootPOA et activer le POAManager
POA rootpoa = (POA) POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// Créer un servant (instance de classe d'implémentation) et l'enregistrer avec l'ORB
SraCorbaImpl sci = new SraCorbaImpl();
/* *** DEBUT INHERITANCE MODEL (vous pouvez vous référer aux chapitres précédents pour utiliser le modèle Tie Delegation Model) *** */
// Récupérer une référence du servant
org.omg.CORBA.Object servantRef = rootpoa.servant_to_reference(sci);
SraCorba sc = SraCorbaHelper.narrow(servantRef);
/* *** FIN INHERITANCE MODEL *** */
// Récupérer la référence du service de nommage
org.omg.CORBA.Object nsRef = orb.resolve_initial_references("NameService");
NamingContextExt nce = NamingContextExtHelper.narrow(nsRef);
// Créer un nom pour le service et ajouter le service
String serviceName = "NameService";
NameComponent nc[] = nce.to_name(serviceName);
nce.rebind(nc, servantRef);
// Démarrer le service et attendre les requêtes des clients
System.out.println("On traite les requêtes des clients ...");
orb.run();
}catch(Exception e) {
e.printStackTrace();
}
}
}
**感謝您幫助我:D **
嘗試:
try{
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialHost","localhost");
props.put("org.omg.CORBA.ORBInitialPort","4321");
ORB orb = ORB.init(args,props);
SraCorbaImpl od = new SraCorbaImpl();
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
byte[] id = rootPOA.activate_object(od);
org.omg.CORBA.Object ref = rootPOA.id_to_reference(id);
String ior = orb.object_to_string(ref);
System.out.println(ior);
rootPOA.the_POAManager().activate();
org.omg.CORBA.Object o = orb.resolve_initial_references("NameService");
NamingContextExt context = NamingContextExtHelper.narrow(o);
NamingContext newContext = context.new_context();
NameComponent[] ctxName = context.to_name("TEST1");
try {
context.bind_context(ctxName,newContext);
} catch(AlreadyBound e) {
newContext = NamingContextHelper.narrow(context.resolve(ctxName));
}
newContext.rebind(context.to_name("B"),ref);
System.out.println("Server running !");
orb.run();
}catch(Exception e){
e.printStackTrace();
}
在這個例子中要小心,我將端口初始化為 4321,所以在啟動 tnameserv 時添加這個選項: tnameserv -ORBInitialPort 4321
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.