Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Corba - J2EE - tnameserv problem  RSS feed

 
Caroline Moran
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an assignment to do for college where we have to connect a corba server (using IDL file). I have the server working perfectly and I have coded a java client and its all working fine.
Now we have to code servlets to connected to the server. We have the servlets started buy seemingly J2EE uses a nameing service called "JNDI" but we are using "tnameserv". Our lecturer said that there is some way of selecting a different port number or something so you can use tnameserv in J2EE but he doesn't know how. If anybody has any idea help would be really appreciated. Here is the code in the servlet that is not working at the moment:
static String username;
static String password;
NamingContext ncRef = null;
NameComponent nc = null;
static directory dir = null;
static manager m1 = null;
String loggedIn="Didnt actually do log in at all";
public void init(ServletConfig config) throws ServletException
{
super.init(config);
String args[]= null;
try
{
// Create and initialize the ORB
ORB orb = ORB.init(args, null);
// Get the root naming context
org.omg.CORBA.Object objRef= orb.resolve_initial_references"NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// Resolve the object reference in naming
NameComponent nc = new NameComponent("directory", "");
NameComponent path[] = {nc};
directory dir = directoryHelper.narrow(ncRef.resolve(path));
}
catch(Exception e)
{
System.out.println("ERROR : " + e);
e.printStackTrace(System.out);
}
}

Thanks
Caroline
 
Marco Barenkamp
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
JNDI is the API for accessing several Nameservices such as ldap or corba nameservices. tnameserv (Transient Name service) is a nameservice. Thus accessible via JNDI.
When you use the 'hardcore' corba way to access a nameservice, you habe to
specify 2 properties:
ORBInitialHost localhost for example
ORBInitialPort 900
.
The tnameserv starts at port 900.
So, add the following line to your code:
args= new String[] { "-ORBInitialHost", "localhost", "-ORBInitialPort", "900" }
This should help. If the nameservice is not running on localhost, enter the appropriate ip address or servername.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!