This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NotBoundException

 
sangeetha balasubramaniam
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to start the rmiregistry and server, but when I start my client, I am left with this error "java.rmi.NotBoundException".
I had checked for the binding name, everything looks correct for me. Pls someone help me
 
amit bhadre
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please send the code...?

thanks
regards
 
sangeetha balasubramaniam
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
public class SellerRegistration{ //Client

/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) {
try{
if(System.getSecurityManager() == null){

System.setSecurityManager(new RMISecurityManager());
}
RemoteInterface sellerInterface = (RemoteInterface)Naming.lookup("Seller");

//Creation of SellerObject from user input(1.Name, 2.Email, 3.TelephoneNumber)
SellerObject sellerObj = new SellerObject();
System.out.println(" Please enter the inputs 1)Name 2)Email 3)Telephone Number in this given order");

//Validate the user input
if(args.length == 3){

sellerObj.setName(args[0]);
sellerObj.setEmail(args[1]);
sellerObj.setTelephoneNumber(Integer.parseInt(args[2]));

}
else{
System.out.println("Invalid Number of user Input");
}

String sellerId = sellerInterface.sellerRegistration(sellerObj);

System.out.println("before writing to Seller Log file");

//Enter the success message for the Registration in Seller's Log File
String filePath= "C:\\j2sdk1.4.2_12\\bin\\DistributedSystems\\SellerLogfile.txt";
String action = "Register";

//Check whether the sellerId is valid to know the correct status
String status = "";
if(sellerId != null && !sellerId.equals("")){
status = "Success";
}else{
status = "Fail";
}
String[] contents = new String[3];
contents[0] = args[0];
contents[1] = args[1];
contents[2] = args[2];
new Service().writeToLog(filePath, action, status, contents);

System.out.println("after writing to Seller Log file");

}catch(Exception e){
System.out.println(e);
}

}
}

=================================

import java.rmi.*;

public class Broker { //Server

/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) {
System.setSecurityManager(new RMISecurityManager());
System.out.println("Main OK");
try{
RemoteInterface sellerInterface = new RemoteServant();
System.out.println("After creating Servant");
Naming.rebind("Seller", sellerInterface);
System.out.println("Broker Ready");
}catch(Exception e){
System.out.println("Broker server main");
}

}
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anything to keep the server "alive" and up after you bind it to the registry? You can use another thread, or just Thread.sleep() to keep your server up and able to receive calls from the client.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic