I am pretty new in Java RMI and i am having a problem of Not Bound Exception. I know there are a lot of posts here but anything i have tried the last hours did not help really..
Here is the code of the server and the client. Any help is good, thanks in advance.
One last thing, the exception is found when i am running Master, when i am running server no errors are found.
Master:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.util.Scanner;
import java.rmi.registry.LocateRegistry;
public class Master {
private ITaskBag1 tb;
private String name = "rmi://" + "127.0.0.1" +":"+1099+"/TaskBagServer";
private int rescount = 0,listcount=0;
private boolean finished = false;
private ArrayList<String> tasks = new ArrayList<String>();
private Random rand;
private double rkey;
public static void main(String[] args){
//pithano lathos
try {
Master m = new Master(args);
} catch (Exception exc) { }
}
Master (String[] args){
rand = new Random();
String url="";
String s1="",s2="",s3="",myLine="",key="";
File myFile=null;
File imgFile = null;
String myFileName="";
String myFileName2="";
StringTokenizer st;
BufferedReader br=null;
int numoftokens = 0;
int endframe = 0;
int degrees = 0;
int eikona = 001;
int i;
double scale = 1.0;
byte[] imageInByte = null;
imageData imdat = null;
imageResult imres = null;
Boolean registered = false;
//Register to ITaskbag
try { //try 1
//try to register
tb = (ITaskBag1) Naming.lookup(name);
}
}
}
Server:
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.LocateRegistry;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
public class TaskBagServer{
public static void main(String args[]) {
final int DEFAULT_PORT = 1099;
String sport="";
int port=DEFAULT_PORT;
String connectionstring="//127.0.0.1/TaskbagServer";
//String porterror = "Invalid port specified, " + DEFAULT_PORT + " assumed";
try {
//LocateRegistry.createRegistry(1099);
// connectionstring = "//127.0.0.1:"+port+"/TaskbagServer";
java.rmi.registry.LocateRegistry.createRegistry(1099);
} catch (RemoteException ex) {
Logger.getLogger(TaskBagServer.class.getName()).log(Level.SEVERE, null, ex);
}
try {
TaskBag1 server = new TaskBag1();
Naming.rebind("connectionstring",server);
System.out.println("Taskbag Server Bound");
}
}
}