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를 통해 전송할 수 없습니다.

참조 : RMI를 통한 스트림 전송 전략