Android-xmlrpc не может сериализовать пользовательский объект - PullRequest
0 голосов
/ 30 января 2012

Я пытаюсь сериализовать объект AnswerObject (поэтому пользовательский объект). Но при запуске logcat выдает:

01-30 13:27:15.553: W/System.err(230): java.io.IOException: Cannot serialize ratedroid.BusinessModels.CourseQuestionAnswer@44f4a920 01-30 13:27:15.604: W/System.err(230): at org.xmlrpc.android.XMLRPCSerializer.serialize(XMLRPCSerializer.java:105) 01-30 13:27:15.604: W/System.err(230): at org.xmlrpc.android.XMLRPCSerializer.serialize(XMLRPCSerializer.java:67) 01-30 13:27:15.604: W/System.err(230): at org.xmlrpc.android.XMLRPCCommon.serializeParams(XMLRPCCommon.java:36) 01-30 13:27:15.604: W/System.err(230): at org.xmlrpc.android.XMLRPCClient.methodCall(XMLRPCClient.java:376) 01-30 13:27:15.604: W/System.err(230): at org.xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:287) 01-30 13:27:15.623: W/System.err(230): at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:424) 01-30 13:27:15.623: W/System.err(230): at nl.purened.ratedroid.RDSC.sendAnswers(RDSC.java:61) 01-30 13:27:15.623: W/System.err(230): at nl.purened.ratedroid.QuestionActivity$1.onClick(QuestionActivity.java:94) 01-30 13:27:15.623: W/System.err(230): at android.view.View.performClick(View.java:2364) 01-30 13:27:15.643: W/System.err(230): at android.view.View.onTouchEvent(View.java:4179) 01-30 13:27:15.643: W/System.err(230): at android.view.View.dispatchTouchEvent(View.java:3709) 01-30 13:27:15.643: W/System.err(230): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 01-30 13:27:15.643: W/System.err(230): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 01-30 13:27:15.653: W/System.err(230): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 01-30 13:27:15.663: W/System.err(230): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 01-30 13:27:15.663: W/System.err(230): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 01-30 13:27:15.663: W/System.err(230): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 01-30 13:27:15.663: W/System.err(230): at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 01-30 13:27:15.673: W/System.err(230): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 01-30 13:27:15.683: W/System.err(230): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 01-30 13:27:15.683: W/System.err(230): at android.os.Handler.dispatchMessage(Handler.java:99) 01-30 13:27:15.683: W/System.err(230): at android.os.Looper.loop(Looper.java:123) 01-30 13:27:15.683: W/System.err(230): at android.app.ActivityThread.main(ActivityThread.java:4363) 01-30 13:27:15.693: W/System.err(230): at java.lang.reflect.Method.invokeNative(Native Method) 01-30 13:27:15.723: W/System.err(230): at java.lang.reflect.Method.invoke(Method.java:521) 01-30 13:27:15.723: W/System.err(230): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 01-30 13:27:15.723: W/System.err(230): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 01-30 13:27:15.723: W/System.err(230): at dalvik.system.NativeStart.main(Native Method) ОШИБКА.

Код объекта:

package ratedroid.BusinessModels;

import java.io.Serializable;

/**
 * The Class Answer.
 */
public class Answer implements Serializable{

/** The Constant serial version uid. */
private static final long serialVersionUID = -6084272301017779054L;

/** The id. */
private int id;

/** The answer. */
private String answer;

/**
 * Instantiates a new answer.
 */
public Answer() {}

/**
 * Instantiates a new answer.
 *
 * @param answer the answer
 */
public Answer(String answer) {
    super();
    this.answer = answer;
}

/**
 * Gets the serial version uid.
 *
 * @return the serial version uid
 */
public static long getSerialversionuid() {
    return serialVersionUID;
}

/**
 * Gets the id.
 *
 * @return the id
 */
public int getId() {
    return id;
}

/**
 * Gets the answer.
 *
 * @return the answer
 */
public String getAnswer() {
    return answer;
}

/**
 * Sets the id.
 *
 * @param id the new id
 */
public void setId(int id) {
    this.id = id;
}

/**
 * Sets the answer.
 *
 * @param answer the new answer
 */
public void setAnswer(String answer) {
    this.answer = answer;
}
}

CourseQuestionAwnser code:

package ratedroid.BusinessModels;

import java.io.Serializable;

// 
/**
 * The Class CourseQuestionAnswer.
 */
public class CourseQuestionAnswer implements Serializable{

/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1873204218188105607L;

/** The id. */
private int id;

/** The course. */
private Course course;

/** The question. */
private Question question;

/** The answer. */
private Answer answer;

/**
 * Instantiates a new course question answer.
 */
public CourseQuestionAnswer() {}

/**
 * Instantiates a new course question answer.
 *
 * @param course the course
 * @param question the question
 * @param answer the answer
 */
public CourseQuestionAnswer(Course course, Question question, Answer answer) {
    super();
    this.course = course;
    this.question = question;
    this.answer = answer;
}

/**
 * Gets the serialversionuid.
 *
 * @return the serialversionuid
 */
public static long getSerialversionuid() {
    return serialVersionUID;
}

/**
 * Gets the id.
 *
 * @return the id
 */
public int getId() {
    return id;
}

/**
 * Gets the course.
 *
 * @return the course
 */
public Course getCourse() {
    return course;
}

/**
 * Gets the question.
 *
 * @return the question
 */
public Question getQuestion() {
    return question;
}

/**
 * Gets the answer.
 *
 * @return the answer
 */
public Answer getAnswer() {
    return answer;
}

/**
 * Sets the id.
 *
 * @param id the new id
 */
public void setId(int id) {
    this.id = id;
}

/**
 * Sets the course.
 *
 * @param course the new course
 */
public void setCourse(Course course) {
    this.course = course;
}

/**
 * Sets the question.
 *
 * @param question the new question
 */
public void setQuestion(Question question) {
    this.question = question;
}

/**
 * Sets the answer.
 *
 * @param answer the new answer
 */
public void setAnswer(Answer answer) {
    this.answer = answer;
}
}

Я нигде не могу найти решение ...

...