0

プロジェクト用に JAX-RPC を使用して Web サービスを作成する必要がありerror: invalid type for JAX-RPC structure: jspf.common.ForumPost、それをコンパイルしようとするとエラーが発生します。JDK 5 と J2EE 1.4 を使用する必要があります。JAX-RPC プラグインと Glassfish v1 サポート プラグインを備えた Netbeans 7.0 を使用して、Application Server PE 9 をコンテナーとして使用しています。

これは私のクラスです:

package jspf.common;

import java.sql.Date;


public class ForumPost extends java.lang.Object implements java.io.Serializable {

    private String poster;
    private String content;
    private int topic_id;
    private int post_id;
    private Date time;

    /**
     * Creates a new ForumPost object.
     * @param poster The username of the user that posted the post.
     * @param content The body/content of the post.
     * @param topic_id The topic ID that this post replies to.
     * @param post_id This post's ID.
     */
    public ForumPost() {
    }

    public ForumPost(int post_id, int topic_id, String poster, String content, Date time) {
        this.poster = poster;
        this.content = content;
        this.topic_id = topic_id;
        this.post_id = post_id;
        this.time = time;
    }

    public Date getTime() {
        return time;
    }

    public String getContent() {
        return content;
    }

    public int getPost_id() {
        return post_id;
    }

    public String getPoster() {
        return poster;
    }

    public int getTopic_id() {
        return topic_id;
    }
}

はい、残念ながらこの古い技術を使用する必要があります。

私は別のクラスで同様の問題を抱えていましたが、ArrayListその中にあった を削除することで修正されたように見えましたが、実際にはそれが必要ですArrayList

このエラーが発生するのはなぜですか?

編集:次のように、java.sql.Date へのすべての参照を削除しました。

package jspf.common;

public class ForumPost extends java.lang.Object implements java.io.Serializable {

    private String poster;
    private String content;
    private int topic_id;
    private int post_id;
    private long time;

    /**
     * Creates a new ForumPost object.
     * @param poster The username of the user that posted the post.
     * @param content The body/content of the post.
     * @param topic_id The topic ID that this post replies to.
     * @param post_id This post's ID.
     */
    public ForumPost() {
    }

    public ForumPost(int post_id, int topic_id, String poster, String content, long time) {
        this.poster = poster;
        this.content = content;
        this.topic_id = topic_id;
        this.post_id = post_id;
        this.time = time;
    }

    public long getTime() {
        return time;
    }

    public String getContent() {
        return content;
    }

    public int getPost_id() {
        return post_id;
    }

    public String getPoster() {
        return poster;
    }

    public int getTopic_id() {
        return topic_id;
    }
}

そして、私はまだ同じエラーが発生します。何が問題なのかわかりません。

4

1 に答える 1

0

問題が見つかりました。J2EE 1.4 ドキュメントで定義されている値型には getter メソッドと setter メソッドが含まれている必要があり、私のクラスには getter メソッドしか含まれていませんでした。

値のタイプ

値型は、メソッド パラメータまたは戻り値としてクライアントとリモート サービスの間で状態を渡すことができるクラスです。たとえば、大学図書館のアプリケーションでは、クライアントは Book という名前の値型パラメーターを使用してリモート プロシージャを呼び出す場合があります。このクラスには、フィールド Title、Author、および Publisher が含まれます。

JAX-RPC でサポートされるには、値の型が次の規則に準拠している必要があります。

  • パブリックの既定のコンストラクターが必要です。
  • java.rmi.Remote インターフェースを (直接的または間接的に) 実装してはなりません。
  • そのフィールドは、サポートされている JAX-RPC タイプでなければなりません。

値の型には、パブリック、プライベート、または保護されたフィールドを含めることができます。値型のフィールドは、次の要件を満たす必要があります。

  • パブリック フィールドは、最終的または一時的であってはなりません。
  • 非パブリック フィールドには、対応するゲッター メソッドとセッター メソッドが必要です。

ソース: http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXRPC4.html#wp130601

于 2012-09-17T07:12:10.820 に答える