• Post Reply Bookmark Topic Watch Topic
  • New Topic

URGENT..pls help me on Dynamic class loading  RSS feed

 
Raukutam Sandeep
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i'm using RMIClassLoader.loadClass(u,"helloClient"),
where u is the object of URL(i gave it as URL u=new URL("http://localhost:8080/")) and helloClient is the name of the class located in public_html directory of JavaWebServer2.0, to load the helloClient class located at the server, into the client. While running the file(java helloLoader) i'm getting the following exceptions:
java.lang.ClassNotFoundException: java.security.AccessControlException: access d
enied (java.net.SocketPermission localhost:8080 connect,resolve)
at java.security.AccessControlContext.checkPermission(Compiled Code)
at java.security.AccessController.checkPermission(AccessController.java:
403)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at sun.rmi.server.LoaderHandler.lookupLoader(Compiled Code)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:274)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:246)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:104)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:77)
at helloLoader.main(helloLoader.java:15)
15th line of helloLoader.java, has a statement like this
Class c=RMIClassLoader.loadClass(u,"helloClient");
and the file contains the following code:

import java.rmi.*;
import java.rmi.server.*;
import java.net.*;
public class helloLoader
{
public static void main(String []a)
{
System.setSecurityManager(new helloSecurity());
try
{
URL u=new URL("http://localhost:8080/");
Class c=RMIClassLoader.loadClass(u,"helloClient");
c.newInstance();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}//end of class
In the above code helloSecurity is the class which implements the 4 policies of RMISecurityManager.
Now, pls tell me why am I getting these exceptions? Is the problem with JWS2.0 or problem with code.
Please help me to solve this problem,
regds,
Sandeep.
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please comment the line System.setSecurityManager and then
try it again.

------------------
Suneel
 
triveni sangam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if u r using Java2 to compile and run ur RMI application, u should have to have a policy file which gives Security permissions to ur classes. This is a new security related concept introduced in jdk 1.2.
U should not get this problem if u use a policy file.I dont have the policy file but u can get it on the net.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!