Search code examples
javaexceptionrmi

java.rmi.MarshalException: ciphering


i get this error when i try to call a remote interface:

java.rmi.MarshalException: error marshalling arguments; nested exception is:    java.io.NotSerializableException: javax.crypto.Cipher

These are the interfaces:

public interface Operacion extends Remote{

 String operacionDesencripta(byte ciphertext[],Key key,Cipher cipher)
        throws RemoteException;

}

and i call it like this:

rmiServidor.operacionDesencripta(ciphertext,key,cipher);

After processing all that data


Solution

  • What is the question exactly? The error is pretty clear -- you cannot serialize the Cipher type. If you check out the Javadoc for this type, it will tell you:

    In order to create a Cipher object, the application calls the Cipher's getInstance method, and passes the name of the requested transformation to it. Optionally, the name of a provider may be specified.

    So instead of passing the Cipher directly, you could pass a transformation string instead (String is serializable and thus "remotable").