NotSerializableException: java.io.FileInputStream [डुप्लिकेट]
Sep 30 2020
मेरा ऐप इस त्रुटि को फेंक रहा है:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.io.FileInputStream
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:194)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:209)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:161)
at com.sun.proxy.$Proxy40.getEntityBlob(Unknown Source)
at com.mycompany.backend.repository.EntityRepositoryImpl.getEntityBlob(EntityRepositoryImpl.java:260)
RMI विधि का "क्लाइंट" पक्ष यह है:
Registry registry = LocateRegistry.getRegistry();
EntityRepository repository =
(EntityRepository) registry.lookup(EntityRepository.class.getName());
return repository.getEntityBlob(appId, namespace, entityType, entityId, blobKey);
और "सर्वर" पक्ष यह है
public InputStream getEntityBlob(
String appId,
String namespace,
String entityType,
final String entityId,
final String blobKey) throws RemoteException {
final InputStream[] inputStream = new InputStream[1];
manager.transactPersistentEntityStore(xodusRoot, appId, true, txn -> {
EntityId idOfEntity = txn.toEntityId(entityId);
final Entity entity = txn.getEntity(idOfEntity);
inputStream[0] = entity.getBlob(blobKey);
});
return inputStream[0];
}
क्या इसका मतलब यह है कि FileInputStreamRMI के साथ काम नहीं कर सकता? या यह काम करना चाहिए और मेरे कोड में कोई समस्या है?
जवाब
quarks Oct 01 2020 at 00:55
यह InputStreamRMI पर प्रसारित करना संभव नहीं है
देखें: आरएमआई पर एक धारा प्रसारित करने की रणनीति