English 中文(简体)
java.lang.Class Not FoundException:accessed to cellloader granted
原标题:java.lang.ClassNotFoundException: access to class loader denied
  • 时间:2012-01-12 10:30:56
  •  标签:
  • java

am a student learning java and got as assignment java RMI I have created 4 files

  1. hellointerface
  2. remotehelloimpl
  3. helloserver
  4. helloclient

I have installed jr6 plugin on eclipse to run the registry on the default port the codes are as follows hellointerface

package demo.rmi.hello.common;
import java.rmi.Remote;
import java.rmi.RemoteException;


public interface helloInterface extends Remote {

    /** This is a sample method. Delete it and add one of your own. */
    public String simpleRemoteMethod(String arg) throws RemoteException;
    public String say() throws RemoteException;

}

<>Remotehelloimpl

 package demo.rmi.hello.server;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import demo.rmi.hello.common.helloInterface;
public class remotehelloImpl extends UnicastRemoteObject implements
helloInterface {
String message;
protected remotehelloImpl(String msg) throws RemoteException {
//super();
// TODO Auto-generated constructor stub
message=msg;
}
public String say() throws RemoteException {
// TODO Auto-generated method stub
return message;
}
@Override
public String simpleRemoteMethod(String arg) throws RemoteException {
    // TODO Auto-generated method stub
    return null;
}
}

code for helloserver

package demo.rmi.hello.server;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import demo.rmi.hello.common.helloInterface;
public class helloserver {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setSecurityManager(new RMISecurityManager());
try {
helloInterface h = new remotehelloImpl("Hello,From Me!");
Naming.rebind("rmi://localhost:1099/HelloService", h);
System.out.println ("Server is connected and ready for operation.");
}
catch (Exception e) {
System.out.println ("Server not connected: " + e);
}
}
}

<><> ∗> 倾角代码:>

package demo.rmi.hello.client;
    import java.rmi.Naming;
    import java.rmi.RMISecurityManager;
    import demo.rmi.hello.common.helloInterface;
    public class helloclient {
    /**
    * @param args
    */
    public static void main (String[] argv) {
    System.setSecurityManager(new RMISecurityManager());
    try {
    helloInterface hello =(helloInterface) Naming.lookup ("rmi://localhost/HelloService");
    System.out.println (hello.say());
    }
    catch (Exception e){
    System.out.println ("HelloClient exception: " + e);}
    }
    }

and i have two security policies (autogenerated on eclipse) policy one // This file was generated by the RMI Plugin for Eclipse.

///////////////////////////////////////////////////////////////
// This is a sample policy file that grants the application all permissions. 
// A policy file is needed by the RMISecurityManager and your application might
// not work after installing the RMISecurityManager unless you provide a 
// security policy file at launch.
//
// You can configure the security policy of a launched application using either
// the RMI Launcher or by manually setting the java.security.policy property.
//
// SECURITY NOTE: This security policy is good for development. For deployment
// you may need a stricter security policy.
//
// For more information see:
//    http://java.sun.com/docs/books/tutorial/rmi/running.html
//    http://java.sun.com/j2se/1.5.0/docs/guide/security/PolicyFiles.html
// 

grant {
    permission java.security.AllPermission;

    // Other options:
    // permission java.net.SocketPermission "127.0.0.1:1024-", "accept, connect, listen, resolve";
    // permission java.net.SocketPermission "localhost:1024-", "accept, connect, listen, resolve";

    // From http://java.sun.com/docs/books/tutorial/rmi/running.html
    // Copyright 1995-2005 Sun Microsystems, Inc. Reprinted with permission 

    // permission java.net.SocketPermission "*:1024-65535", "connect,accept";
    // permission java.net.SocketPermission "*:80", "connect";

    // permission java.net.SocketPermission "*:1024-65535", "connect,accept";
    // permission java.io.FilePermission "c:\home\ann\public_html\classes\-", "read";
    // permission java.io.FilePermission "c:\home\jones\public_html\classes\-", "read";
};

* 安保政策2

   // This file was generated by the RMI Plugin for Eclipse.

///////////////////////////////////////////////////////////////
// This is a sample policy file that grants the application all permissions. 
// A policy file is needed by the RMISecurityManager and your application might
// not work after installing the RMISecurityManager unless you provide a 
// security policy file at launch.
//
// You can configure the security policy of a launched application using either
// the RMI Launcher or by manually setting the java.security.policy property.
//
// SECURITY NOTE: This security policy is good for development. For deployment
// you may need a stricter security policy.
//
// For more information see:
//    http://java.sun.com/docs/books/tutorial/rmi/running.html
//    http://java.sun.com/j2se/1.5.0/docs/guide/security/PolicyFiles.html
// 

grant {
    permission java.security.AllPermission;

    // Other options:
    // permission java.net.SocketPermission "127.0.0.1:1024-", "accept, connect, listen, resolve";
    // permission java.net.SocketPermission "localhost:1024-", "accept, connect, listen, resolve";

    // From http://java.sun.com/docs/books/tutorial/rmi/running.html
    // Copyright 1995-2005 Sun Microsystems, Inc. Reprinted with permission 

    // permission java.net.SocketPermission "*:1024-65535", "connect,accept";
    // permission java.net.SocketPermission "*:80", "connect";

    // permission java.net.SocketPermission "*:1024-65535", "connect,accept";
    // permission java.io.FilePermission "c:\home\ann\public_html\classes\-", "read";
    // permission java.io.FilePermission "c:\home\jones\public_html\classes\-", "read";
};

i 首先从登记处开始,然后是连续的,但正出现以下错误:

Server not connected: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: access to class loader denied
问题回答

参看,该网址是,就“被拒绝进入班轮”问题进行会谈。

此外,你没有在客户代码中具体说明1099号港口。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签