aspose file tools*
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
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "CORBA beginner, help needed" Watch "CORBA beginner, help needed" New topic
Author

CORBA beginner, help needed

himanshu verma
Greenhorn

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(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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CORBA beginner, help needed