Skip to content
Advertisement

java RMI – unexpected error

I have been working on to create a sample RMI project for a while and having difficulty with the following error for a few hours now. If anyone of you can point me towards my mistake, I will be grateful. I will be posting the trimmed code with the error.

Thanks in advance for your time.

PrimeFinder.java

import //irrelevant

public interface PrimeFinder extends Remote 
{
    public List<Integer> findPrime (int startPoint, int endPoint )
        throws RemoteException;
}

PrimeFinderService.java

import //irrelevant

public class PrimeFinderService extends UnicastRemoteObject
implements PrimeFinder
{
    public PrimeFinderService () throws RemoteException
    {
        super();
    }


    public List<Integer> findPrime(int startPoint, int endPoint)
            throws RemoteException {

        // Irrelevant
    }

    public static void main ( String args[] ) throws Exception
    {
        if (System.getSecurityManager() == null)
            System.setSecurityManager ( new RMISecurityManager() );

        PrimeFinderService svr = new PrimeFinderService();
        Naming.bind ("PowerService", svr);

        System.out.println ("Service bound....");
    }
}

.policy

grant {
    permission java.security.AllPermission; }

The error that is killing me :

Exception in thread "main" 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
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
    at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
    at java.rmi.Naming.bind(Naming.java:128)
    at q7.PrimeFinderService.main(PrimeFinderService.java:69)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: access to class loader denied
    at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: access to class loader denied
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:445)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:182)
    at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637)
    at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:264)
    at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:214)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1592)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
    ... 12 more
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission /home/cem/workspace/OBSS_q7/bin/q7/- read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
    at java.security.AccessController.checkPermission(AccessController.java:553)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at sun.rmi.server.LoaderHandler$Loader.checkPermissions(LoaderHandler.java:1173)
    at sun.rmi.server.LoaderHandler$Loader.access$000(LoaderHandler.java:1127)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:409)
    ... 21 more

Edit 1:

The error line that I’m trying to overcome is:

 Caused by: java.security.AccessControlException: access denied (java.io.FilePermission /home/cem/workspace/OBSS_q7/bin/q7/- read)

I have tried at least 10 different approaches in my .policy file – all of which ended up with the same problem. I have tried anything in the tutorials I have found and it’s I believe safe to say that the problem doesn’t lie in .policy file.

I have also meddled with the codebase, giving the codebase wrong ends up with different errors so that can’t be it either.

Still looking for ideas ^^

Cheers !

Advertisement

Answer

The problem was regarding linux file system permissions, altering permissions fixes the problem.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement