File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes NotBoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "NotBoundException" Watch "NotBoundException" New topic
Author

NotBoundException

sangeetha balasubramaniam
Greenhorn

Joined: May 16, 2005
Posts: 23
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

Joined: Jan 23, 2006
Posts: 124
Please send the code...?

thanks
regards


Thanks advance who ever answers this question.


regards
amit bhadre
sangeetha balasubramaniam
Greenhorn

Joined: May 16, 2005
Posts: 23
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

Joined: Oct 18, 2000
Posts: 4121

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.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NotBoundException
 
Similar Threads
java study
Book for Spring Hibernate
java study
Start Using Hibernate
Learning Unix/Linux