• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CORBA beginner, help needed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic