This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes java.rmi. NotBoundException: Student1001? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "java.rmi. NotBoundException: Student1001?" Watch "java.rmi. NotBoundException: Student1001?" New topic
Author

java.rmi. NotBoundException: Student1001?

darine darine
Ranch Hand

Joined: Mar 08, 2001
Posts: 43
Hello All
after i got:
C:\csc193\examples\network>java -Djava..rmi.server.codebase=file:/..\..\ -D
java.security.policy=RMISecurity.policy examples.network.StudentEnrollment
student objects bound .
what does that(the exception) mean?how can i fix that?
do i need to set up anything?
thanks for your time.
here is the full exception:
===========================
C:\csc193\examples\network>java -Djava.security.policy=RMISecurity.policy e
xamples.network.StudentClient
java.rmi.NotBoundException: Student1001
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(U
nknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at examples.network.StudentClient.main(StudentClient.java:17)
===========================
here are my app's files:
=============================
grant
{
permission java.net.SocketPermission "*:1024-65535",
"connect,accept";

};
============================
package examples.network;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Student extends Remote
{
public int getID() throws RemoteException;
public void setName(String name) throws RemoteException;
public String getName() throws RemoteException;
public int getCredits() throws RemoteException;
public int addCredits(int credits) throws RemoteException;

}
=======================================
package examples.network;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
public class StudentClient
{
private static final String HOST_NAME="localhost";
public static void main(String s[])
{
if(System.getSecurityManager()==null)
{
System.setSecurityManager(new RMISecurityManager());
}

try
{
Student s1001=(Student) Naming.lookup("//"+HOST_NAME+"/Student1001");
Student s1005=(Student) Naming.lookup("//"+HOST_NAME+"/Student1005");
System.out.println(s1001.getName());
System.out.println(s1005.getName());
System.out.println(s1001.getCredits());
s1001.addCredits(3);
s1001.setName("Elaine Goldman");
System.out.println(s1001.getName());
System.out.println(s1001.getCredits());
}
catch(Exception x)
{
x.printStackTrace();
}
}

}
===============================
package examples.network;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
public class StudentEnrollment
{
public static void main(String s[])
{
if(System.getSecurityManager()==null)
{
System.setSecurityManager(new RMISecurityManager());
}

try
{
StudentImpl[] students=
{
new StudentImpl( 1001,"Matt1 "),
new StudentImpl( 1002,"Matt2 "),
new StudentImpl( 1003,"Matt3 "),
new StudentImpl( 1004,"Matt4 "),
new StudentImpl( 1005,"Matt5 ")
};
for(int i=0;i<students.length;i++)
{
int id =students[i].getID();
Naming.rebind("student"+id,students[i]);
}
System.out.println("student objects bound .");
}
catch(Exception x)
{
x.printStackTrace();
}
}

}
==================================
package examples.network;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public class StudentImpl extends UnicastRemoteObject
implements Student
{
private int ID;
private String name;
private int credits=0;
public StudentImpl(int ID,String name)throws RemoteException
{
this.ID=ID;
this.name=name;
}
public int getID() throws RemoteException
{
return ID;
}
public void setName(String name) throws RemoteException
{
this.name=name;
}
public String getName() throws RemoteException
{
return name;
}
public int getCredits() throws RemoteException
{
return credits;
}
public int addCredits(int credits) throws RemoteException
{
return (this.credits +=credits);
}

}
============================================
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Use Naming.list() in your client code. This will prompt the registry to show you all registered elements it currently has. Then just make sure
the names you're looking for in your client code match up.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.rmi. NotBoundException: Student1001?
 
Similar Threads
java.rmi.UnmarshalException?
java.rmi.ConnectException
java.security AccessControlException : access denied?
java.rmi.UnmarshalException?
RMI Project