я получаю сообщение об ошибке:
NotSerializableException даже при использовании переходных
WARNING: Cannot serialize session attribute DocumentFieldHelper for session {idsession} java.io.NotSerializableException: com.example.DocumentKind
while trying to Serialize class DocumentFieldHelper.
Код для DocumentFieldHelper
private class DocumentFieldHelper implements Serializable
{
private static final long serialVersionUID = 1L;
private Map<String, Object> fieldValues;
private String documentKind;
public DocumentFieldHelper()
{
fieldValues = new HashMap<String, Object>();
}
public NativeDockindQuery createQuery()
{
try
{
NativeDockindQuery ndq = NativeDockindQuery.create(this.getDocumentKind());
return ndq;
} catch (EdmException e)
{
log.error(e.getMessage(), e);
}
return null;
}
public String getDocumentKind() {
return documentKind;
}
Код для NativeDockindQuery
public class NativeDockindQuery implements Serializable {
private static final long serialVersionUID = -2001430456575525419L;
private transient DocumentKind kind;
public static NativeDockindQuery create(String kind) throws EdmException {
return new NativeDockindQuery(DocumentKind.findByCn(kind), false);
}
private NativeDockindQuery(DocumentKind kind, boolean checkPermissions) throws EdmException {
this.kind = kind;
}
}
Конечно, есть еще код но я думаю, что это важная часть.
Я предполагаю, что NativeDockindQuery должен быть Serializable, потому что это тип возврата в одном из методов DocumentFieldHelper?
Возможно ли, что у меня есть эта проблема, потому что я использую статический метод из DocumentKind?
Что входит в 'fieldValues'? – Vlad
Я вижу два ** documentKind **. Тот, который является строковой переменной в вашем ** DocumentFieldHelper **, а другой выглядит как тип класса в ** NativeDockindQuery **. Так все в порядке? Я имею в виду, вы что-то тут что-то приняли? – SacJn
Vlad - fieldValues Переменные объекта - это примитивы типа int, long и String. Ничего, что не может быть сериализовано (например, как DocumentKind, которое указано в описании ошибки) – user3597356