我正在尝试使用其余的Web服务来获取扩展SportEvent的SportMatchEvent对象的列表
此rest方法位于ejb中。在我的测试中,如果我尝试使用rest方法返回一个可以工作的String对象,但是我需要返回SportMatchEvents对象的列表。
我的体系结构如下:
实现远程ejb接口的ejb具有以下架构:
@Path("eventosdeportivos")
@Singleton
public class ConwSportEventArrayList extends CopyOnWriteArrayList<SportEvent> implements RemoteConwSportEventsService, Serializable {
.......
@Override
@GET
@Produces(value = {MediaType.APPLICATION_XML})
@Path("/eventos")
public Response restGetSportEventsAsList() {
List<SportMatchEvent> sportMatchEventsList = new ArrayList<>();
for(SportEvent sportEvent : this.getSportEventsAsList()){
if(sportEvent instanceof SportMatchEvent){
sportMatchEventsList.add((SportMatchEvent)sportEvent);
}
}
return Response.status(Response.Status.OK).entity(sportMatchEventsList).build();
}
}
@XmlRootElement
public class SportMatchEvent extends SportEvent{
.....
.....
public SportMatchEvent(Sports sport, Competitions competition,Date date,Date eventCutDate, Boolean inPlay, String homeTeamName, String awayTeamName ){
super(sport, competition,date, eventCutDate, inPlay);
this.homeTeamName = StringUtils.stripAccents(homeTeamName).toUpperCase();
this.awayTeamName = StringUtils.stripAccents(awayTeamName).toUpperCase();
this.eventName = generateEventName(this.homeTeamName, this.awayTeamName);
this.eventId = generateEventId();
}
}
public abstract class SportEvent implements Serializable{
....
....
}
我从Glassfish中得到的调用rest方法的错误是:
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.ClassCastException: org.glassfish.jersey.message.internal.OutboundJaxrsResponse cannot be cast to java.io.Serializable
root cause
java.lang.ClassCastException: org.glassfish.jersey.message.internal.OutboundJaxrsResponse cannot be cast to java.io.Serializable