クライアントとサーバーの2つの単純なアプリケーションがあります。クライアントは(単純なAES)カスタムオブジェクトを暗号化し、TCPソケットを介してバイトとしてサーバーに送信します。サーバーはこれらのバイトを復号化し、次のようにこのオブジェクトを再作成するメソッドを呼び出します。
private static Object getObjectFromBytes(byte[] credentials) throws IOException,      ClassNotFoundException{
    ByteArrayInputStream bis = new ByteArrayInputStream(credentials);
    ObjectInput in = null;
    Object credentialsObj = null;
    try {
        in = new ObjectInputStream(bis);
        credentialsObj = in.readObject(); 
    } finally {
      bis.close();
      in.close();
    }
    return credentialsObj;
}
クライアント側では、このオブジェクトを暗号化するとき、タイプはmds.hm5.client.ITU_Credentialsです。サーバー側では、復号化してオブジェクトに変換し直すときは、である必要がありますmds.hm5.tokenservice.ITU_Credentials。代わりに、次の例外が発生します。
java.lang.ClassNotFoundException: mds.hm5.client.ITU_Credentials
彼は古いクラスパスでこのオブジェクトを探しています。なぜそれが起こっているのですか、そしてどのようにそれを修正する必要がありますか?
追加情報:
このオブジェクトをクライアント側でバイト配列に変換する方法は次のとおりです。
private static byte[] getBytesFromObject(Object credentials) throws IOException{
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutput out = null;
    byte[] newBytes = null;
    try {
      out = new ObjectOutputStream(bos);   
      out.writeObject(credentials);
      newBytes = bos.toByteArray();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
      out.close();
      bos.close();
    }
    return newBytes;
}   
ジェネリック型を使用する理由Objectは、これらのメソッドを使用して複数の型を変換/暗号化/復号化するためです。それは適切な方法ですか?