IPC JSR 286 complex object as event
natoine Mar 5, 2010 12:18 PMI try to communicate an objetc from a portlet to another using EventPortlet.
My event is a serializable object.
I have the following error when testing my portlets :
Cause: java.lang.IllegalArgumentException: The provided event value type fr.natoine.annotations_persistence.selection.SelectionHTML does not have a valid jaxb annotation
Message: The provided event value type fr.natoine.annotations_persistence.selection.SelectionHTML does not have a valid jaxb annotation
My object/event code :
@Entity
public class SelectionHTML extends Selection
{
@Column(name = "SELECTIONHTML_CONTENT")
private String content;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
SelectionHTML extends Selection :
@MappedSuperclass
@Table(name = "SELECTION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Selection implements Serializable
{
@Id @GeneratedValue
@Column(name = "SELECTION_ID")
private Long id;
@Column(name = "SELECTION_URL_SOURCE")
private String url_source;
@Column(name = "SELECTION_BEGIN")
private String begin;
@Column(name = "SELECTION_END")
private String end;
public Selection(){};
public Long getId() {
return id;
}
public String getUrl_source() {
return url_source;
}
public void setUrl_source(String urlSource) {
url_source = urlSource;
}
public String getBegin() {
return begin;
}
public void setBegin(String begin) {
this.begin = begin;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
}
I use Hibernate Annotations cause i use these classes for persistence.
I declare my event in portlet.xml :
<event-definition> <qname>annotation-selection</qname> <value-type>fr.natoine.annotations_persistence.selection.Selection</value-type> </event-definition>
And i send my event :
SelectionHTML _selection_html = new SelectionHTML();
_selection_html.setUrl_source(request.getParameter("url"));
_selection_html.setContent(request.getParameter("text_selection"));
_selection_html.setBegin(request.getParameter("xpointer_start"));
_selection_html.setEnd(request.getParameter("xpointer_end"));
response.setEvent("annotation-selection", _selection_html);