【发布时间】:2012-09-17 06:41:10
【问题描述】:
我必须使用 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;
}
}
我仍然遇到同样的错误。我不明白问题是什么。
【问题讨论】:
标签: java web-services jax-rpc