File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes CORBA beginner, help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "CORBA beginner, help needed" Watch "CORBA beginner, help needed" New topic

CORBA beginner, help needed

himanshu verma

Joined: Dec 05, 2011
Posts: 3

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(

package demo.hello;

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 );

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));

// wait for requests;
catch( Exception e )
//System.out.println( e );

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

jQuery in Action, 2nd edition
subject: CORBA beginner, help needed