I have to make a web service using JAX-RPC for a project and I get error: invalid type for JAX-RPC structure: jspf.common.ForumPost when trying to compile it. We have to use JDK 5 and J2EE 1.4. I’m using Netbeans 7.0 with the JAX-RPC plugin and Glassfish v1 support plugin to use Application Server PE 9 as my container.
This is my class:
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;
}
}
Yes, I have to use this old technology unfortunately.
I was having similar issues with another class but that seemed to be fixed by removing the ArrayList that was within it, but I actually need that ArrayList.
Why am I getting this error?
EDIT: I got rid of all references to java.sql.Date, as follows:
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;
}
}
And I still get the same error. I don’t understand what the problem is.
I found the problem. Value types as defined in the J2EE 1.4 documentation must contain getter and setter methods, my class contained only getter methods.
Source: http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXRPC4.html#wp130601