GeeCON Prague 2014*
The moose likes Distributed Java and the fly likes Dynamic stub downloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Dynamic stub downloading" Watch "Dynamic stub downloading" New topic
Author

Dynamic stub downloading

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
i am trying dynamic stub downloading but getting following error
message when stub gets downloaded..........
------------------------------------------------------------
Exception in thread "main" java.lang.IllegalAccessError: class server_Stub cannot access its superinterface remoteI
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.inputClassDescriptor(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.inputObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at client.main(client.java:16)
------------------------------------------------------------
I had started rmiregistry after setting no classpath.
My server and client files are in seperate directories.
In server directory classpath is current directory only)
---------------------
remoteI.class (interface class)
server.class (main server program)
server_Stub.class
server_Skel.class
policy (policy file having all permission set)
---------------------
in client directory classpath is current directory only)
--------------------------
client.class (client program)
remoteI.class (interface class)
policy (All permissions granted)
--------------------------
---------client.java------------------------
public class client
{
public static void main(String []s)
{
System.setSecurityManager(new RMISecurityManager());
try
{
remoteI _server=(remoteI)Naming.lookup("rmi://"+"192.168.1.78"+"/"+"Test");
System.out.println(_server.getMessage());


}catch(Exception e)
{
e.printStackTrace();
}
}
}
---------------------------------

Now what is the problem.Why downloaded stub is not able to access interface class?
I have already set all permission in the policy file.
please send reply soon
Thanks in advance....
Milind Kulkarni
Ranch Hand

Joined: Jun 01, 2000
Posts: 146
1> Kill all the previous processes on that port.
2> In order to use RMI in JDK 1.2 and beyond, you would have to create a policy file and specify it on the command-line when you run your class file using command "Java". It is because in order to use RMI, you have to install the RMISecurityManager using the call "System.setSecurityManager(new RMISecurityManager())" and this security manager does not allow socket communications unless you explicitly allow them in the policy file.
3> Check your policy file. Write a simple policy file and see if you are encountering the same exceptions.
Here is a simple policy file:
grant {
permission java.security.AllPermission "", "";
};
Regards,
Milind
 
 
subject: Dynamic stub downloading