• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CORBA beginner, help needed

 
himanshu verma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i am new to CORBA. M getting exception
java.lang.ClassCastException: demo.hello.GoodDayImpl cannot be cast to org.omg.CORBA.Object
at demo.hello.Server.main(Server.java:30)


package demo.hello;

import java.io.*;
import org.omg.CORBA.*;
import org.omg.CORBA.Object;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextHelper;
//import org.omg.PortableServer.*;


public class Server
{
public static void main(String[] args)
{
if( args.length != 1 )
{
System.out.println("Usage: jaco demo.hello.Server <ior_file>");
System.exit( 1 );
}

try
{
ORB orb = ORB.init( args, null );
GoodDayImpl goodDayImpl = new GoodDayImpl("Somewhere");
orb.connect( (Object) goodDayImpl);
org.omg.CORBA.Object objRef =orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
NameComponent nc = new NameComponent("HelloWorld", " ");
NameComponent path[] = {nc};
ncRef.rebind(path, (Object) goodDayImpl);
System.out.println("Server started....");

PrintWriter pw =new PrintWriter( new FileWriter( args[ 0 ] ));
System.out.println("got here");
// print stringified object reference to file
pw.println( orb.object_to_string( (Object) goodDayImpl ));
System.out.println(orb.object_to_string( (Object) goodDayImpl));
pw.flush();
pw.close();

// wait for requests
orb.run();
}
catch( Exception e )
{
e.printStackTrace();
//System.out.println( e );
}
}
}


i juat want to register an object in naming service in server and use it on client.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic