hi
ich habe folgende fehlermeldung (beim ausführen von server programm) weis aber nich wieso und wie ich es bechebe:
meine IDL datei:
mein Client:
mein server:
compiliert wird wie folgt:
idlj -fall ...idl
javac Server.java Bestellung\*.java
javac Client.java
ausführung
tnameserv
java Server
java Client
ich habe folgende fehlermeldung (beim ausführen von server programm) weis aber nich wieso und wie ich es bechebe:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/omg/PortableServer/Servant
meine IDL datei:
Code:
module Bestellung
{
interface DB_Manager
{
string getText();
long getAnzahl();
};
};
mein Client:
Code:
import Bestellung.*;
import org.omg.CosNaming.*;
//import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class Client
{
static DB_Manager DB_ManagerImpl;
public static void main(String args[])
{
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt instead of NamingContext. This is
// part of the Interoperable naming Service.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// resolve the Object Reference in Naming
DB_Manager serverRef = DB_ManagerHelper.narrow(ncRef.resolve_str("DB_Manager"));
String text = serverRef.getText();
System.out.println(text);
int zahl = serverRef.getAnzahl();
System.out.println("der " + zahl + ". Aufruf");
}
catch (Exception e) {
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}
mein server:
Code:
import Bestellung.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import java.util.Properties;
//import java.sql.*;
//import java.util.*;
class DB_ManagerImpl extends DB_ManagerPOA
{
int zaehler = 0;
public String getText()
{
return "\nHallo, hier ist der Server\n";
}
public int getAnzahl()
{
return ++zaehler;
}
}
public class Server {
public static void main(String args[]) {
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa & activate the POAManager
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// create servant and register it with the ORB
DB_ManagerImpl serverImpl = new DB_ManagerImpl();
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(serverImpl);
DB_Manager sRef = DB_ManagerHelper.narrow(ref);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// bind the Object Reference in Naming
NameComponent path[] = ncRef.to_name( "DB_Manager" );
ncRef.rebind(path, sRef);
// wait for invocations from clients
orb.run();
}
catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
}
}
compiliert wird wie folgt:
idlj -fall ...idl
javac Server.java Bestellung\*.java
javac Client.java
ausführung
tnameserv
java Server
java Client