Getting Started with Java IDL:Developing the Hello World Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    Getting Started with Java IDL:Developing the Hello World Server

    i m trying to write a hello world server but i get the following 3 errors
    cd u please help me

    javac HelloServer.jav a HelloApp/*.java
    HelloServer.jav a:52: cannot find symbol
    symbol: class _HelloImplBase
    class HelloServant extends _HelloImplBase
    ^
    HelloServer.jav a:26: connect(org.omg .CORBA.Object) in org.omg.CORBA.O RB cannot b
    e applied to (HelloServant)
    orb.connect(hel loRef);
    ^
    HelloServer.jav a:35: rebind(org.omg. CosNaming.NameC omponent[],org.omg.CORBA. Obje
    ct) in org.omg.CosNami ng.NamingContex tOperations cannot be applied to (org.omg.C
    osNaming.NameCo mponent[],HelloServant)
    ncRef.rebind(pa th, helloRef);
    ^
    Note: HelloApp\HelloP OA.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    3 errors
  • oll3i
    Contributor
    • Mar 2007
    • 679

    #2
    and the hello server looks like this

    Code:
    // The package containing our stubs.
    import HelloApp.*;
    
    // HelloServer will use the naming service.
    import org.omg.CosNaming.*;
    
    // The package containing special exceptions thrown by the name service.
    import org.omg.CosNaming.NamingContextPackage.*;
    
    // All CORBA applications need these classes.
    import org.omg.CORBA.*;
    
    
    
    public class HelloServer 
    {
      public static void main(String args[])
      {
        try{
        
          // Create and initialize the ORB
          ORB orb = ORB.init(args, null);
          
          // Create the servant and register it with the ORB
          HelloServant helloRef = new HelloServant();
          orb.connect(helloRef);
          
          // Get the root naming context
          org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
          NamingContext ncRef = NamingContextHelper.narrow(objRef);
          
          // Bind the object reference in naming
          NameComponent nc = new NameComponent("Hello", " ");
          NameComponent path[] = {nc};
          ncRef.rebind(path, helloRef);
          
          // Wait for invocations from clients
          java.lang.Object sync = new java.lang.Object();
          synchronized(sync){
            sync.wait();
          }
          
        } catch(Exception e) {
            System.err.println("ERROR: " + e);
            e.printStackTrace(System.out);
          }  
      }
    }
    
    
    
    class HelloServant extends _HelloImplBase
    {
      public String sayHello()
      {
        return "\nHello world!!\n";
      
      }
    }

    Comment

    • oll3i
      Contributor
      • Mar 2007
      • 679

      #3
      idlj -fall Hello.idl didnt generate the _HelloImplBase. java

      Comment

      • vijayflex
        New Member
        • Feb 2014
        • 1

        #4
        Instead of trying "idlj -fall Hello.idl" command try this command "idlj -fall -oldImplBase -keep Hello.idl". This command will generate _HelloImplBase. java. Then go to HelloServer.jav a --->> add one more empty member function to the class "HelloServa nt"
        public void shutdown()
        {

        }
        Hope this will help. :-)

        Comment

        Working...