Java 解组时出现JAXB意外元素错误

Java 解组时出现JAXB意外元素错误,java,web-services,jboss,wsdl,jax-ws,Java,Web Services,Jboss,Wsdl,Jax Ws,如果有人能为我的问题找到解决方案,我将不胜感激 从我的web服务调用web方法时,出现以下错误: [com.sun.istack.SAXParseException2;行号:1;列号:223;意外元素(uri:,local:,sport”)。预期元素为,,,,,,] 我想知道为什么消息中包含“sport”元素,为什么它与。我认为这与名称空间有关,但我无法解决这个问题,到目前为止我已经被困了两个晚上 我正在使用JBossWS工具生成客户端web服务,所有内容都部署在JBoss 7.1.1上(但我认

如果有人能为我的问题找到解决方案,我将不胜感激

从我的web服务调用web方法时,出现以下错误:

[com.sun.istack.SAXParseException2;行号:1;列号:223;意外元素(uri:,local:,sport”)。预期元素为,,,,,,]

我想知道为什么消息中包含“sport”元素,为什么它与。我认为这与名称空间有关,但我无法解决这个问题,到目前为止我已经被困了两个晚上

我正在使用JBossWS工具生成客户端web服务,所有内容都部署在JBoss 7.1.1上(但我认为这与此无关)。请至少给我一些线索:)

下面是游戏评分课:

@Entity
@Table(name = "`GAMESCORING`")
@XmlRootElement
@XmlType(name = "GameScoring", propOrder = { "gameScoringId", "scoring", "finished", "startTime", "stopTime",
    "tiebreak" })
public class GameScoring implements Serializable {
@Id
@GeneratedValue
@Column(name = "game_scoring_id")
private long gameScoringId;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "scoring")
private List<GamePeriod> periods;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "scoring_id")
private Scoring scoring;

private boolean finished;

private Date startTime;

private Date stopTime;

private GamePeriod tiebreak;

public GameScoring() {
    super();
}
如何调用web服务方法:

GameManagerService gm_service = new GameManagerService();
GameManagerPortType gm_port = gm_service.getGameManagerPort();
com.lskings.lsep.ws.sdl.Game game = gm_port.getMostFavored();
这里是web服务SEI:

@WebService(name = "GameManagerPortType")
@SOAPBinding(style = Style.RPC, use = Use.LITERAL)
public interface GameManagerEndpoint {

@WebMethod
@WebResult(name = "success")
public boolean addGame(
        @WebParam(name = "sportId") String sportId,
        @WebParam(name = "leagueId") String leagueId,
        @WebParam(name = "scoringId") String scoringId,
        @WebParam(name = "participantHomeId") long participantHomeId,
        @WebParam(name = "participantAwayId") long participantAwayId);

@WebMethod
@WebResult(name = "success")
public boolean deleteGame(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "exists")
public boolean exists(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "game")
public Game getGame(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameList")
public List<Game> getGamesForLeague(@WebParam(name = "leagueId") long leagueId);

@WebMethod
@WebResult(name = "gameList")
public List<Game> search(@WebParam(name = "query") String query);

@WebMethod
@WebResult(name = "gameList")
public List<Game> getGamesForSport(@WebParam(name = "sportId") long sportId);

@WebMethod
@WebResult(name = "game")
public Game getMostFavored();

@WebMethod
@WebResult(name = "success")
public boolean setMostFavored(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gamePeriods")
public List<GamePeriod> getPeriods(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gamePeriodsWithTiebreaks")
public List<GamePeriod> getPeriodsWithTiebreaks(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameScore")
public int[] getScore(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "periodActions")
public List<GameAction> getPeriodActions(@WebParam(name = "periodId") long periodId);

@WebMethod
@WebResult(name = "allActions")
public List<GameAction> getAllActions(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameTimer")
public String getGameTimer(@WebParam(name = "gameId") long gameId);

}

几天前我发现它与@manytone和@ManyToMany JPA注释有关。但是,我不知道为什么在使用这些注释时失败,@xmltransive注释解决了这个问题。之后,我只需要编写一些额外的代码,以便通过id获取相关对象。

您能在服务器和客户端上显示
游戏
类的代码吗?我刚刚将它们添加到我的原始问题中。不幸的是,我需要删除stak跟踪的一部分——post太长了……在这种情况下,堆栈跟踪通常是非常可修剪的;它们往往非常长,并且很少有感兴趣的帧。您可以始终在pastebin上放置非常长的堆栈跟踪,并将它们链接到此处:)此外,在这种情况下,可以帮助您执行一些连线级别的跟踪,以查看从服务器发回的实际xml是什么。如果您在Eclipse中,您可以尝试TCP/IP监视器视图。另外,检查post,它可能会有所帮助。
@WebService(name = "GameManagerPortType")
@SOAPBinding(style = Style.RPC, use = Use.LITERAL)
public interface GameManagerEndpoint {

@WebMethod
@WebResult(name = "success")
public boolean addGame(
        @WebParam(name = "sportId") String sportId,
        @WebParam(name = "leagueId") String leagueId,
        @WebParam(name = "scoringId") String scoringId,
        @WebParam(name = "participantHomeId") long participantHomeId,
        @WebParam(name = "participantAwayId") long participantAwayId);

@WebMethod
@WebResult(name = "success")
public boolean deleteGame(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "exists")
public boolean exists(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "game")
public Game getGame(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameList")
public List<Game> getGamesForLeague(@WebParam(name = "leagueId") long leagueId);

@WebMethod
@WebResult(name = "gameList")
public List<Game> search(@WebParam(name = "query") String query);

@WebMethod
@WebResult(name = "gameList")
public List<Game> getGamesForSport(@WebParam(name = "sportId") long sportId);

@WebMethod
@WebResult(name = "game")
public Game getMostFavored();

@WebMethod
@WebResult(name = "success")
public boolean setMostFavored(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gamePeriods")
public List<GamePeriod> getPeriods(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gamePeriodsWithTiebreaks")
public List<GamePeriod> getPeriodsWithTiebreaks(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameScore")
public int[] getScore(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "periodActions")
public List<GameAction> getPeriodActions(@WebParam(name = "periodId") long periodId);

@WebMethod
@WebResult(name = "allActions")
public List<GameAction> getAllActions(@WebParam(name = "gameId") long gameId);

@WebMethod
@WebResult(name = "gameTimer")
public String getGameTimer(@WebParam(name = "gameId") long gameId);

}
 @Entity
 @Table(name = "`GAME`")
 @XmlRootElement
 @XmlType(name = "Game", propOrder = { "gameId", "sport", "mostFavored" })
 public class Game implements Serializable {

private static final long serialVersionUID = -1564911377701558631L;

@Id
@GeneratedValue
@Column(name = "game_id")
private long gameId;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "sport_id")
private Sport sport;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "scoring_id")
private Scoring scoring;

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "game_scoring_id")
private GameScoring gameScoring;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "teamA_id")
private Participant teamA;

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "teamB_id")
private Participant teamB;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "league_id")
private League league;

@Column(name = "most_favored")
private boolean mostFavored;

public Game() {
    super();
}

public Game(Sport sport, Scoring scoring, Participant teamA, Participant teamB) {
    this(sport, scoring, teamA, teamB, null);
}

public Game(Sport sport, Scoring scoring, Participant teamA, Participant teamB, League league) {
    super();
    this.sport = sport;
    this.scoring = scoring;
    this.teamA = teamA;
    this.teamB = teamB;
    this.league = league;
    this.mostFavored = false;

    LinkedList<GamePeriod> periods = new LinkedList<GamePeriod>();

    this.gameScoring = new GameScoring();

    Period p = scoring.getPeriods().get(0);
    GamePeriod gp = new GamePeriod(p, gameScoring);
    periods.add(gp);
    gp.generateParents(true);

    gameScoring.setPeriods(periods);
    gameScoring.setScoring(scoring);
}

public Sport getSport() {
    return sport;
}

@XmlTransient
public Scoring getScoring() {
    return scoring;
}

@XmlTransient
public Participant getTeamA() {
    return teamA;
}

@XmlTransient
public Participant getTeamB() {
    return teamB;
}

@XmlTransient
public GameScoring getGameScoring() {
    return gameScoring;
}

public void setSport(Sport sport) {
    this.sport = sport;
}

public void setScoring(Scoring scoring) {
    this.scoring = scoring;
}

public void setGameScoring(GameScoring gameScoring) {
    this.gameScoring = gameScoring;
}

public void setTeamA(Participant teamA) {
    this.teamA = teamA;
}

public void setTeamB(Participant teamB) {
    this.teamB = teamB;
}

public long getGameId() {
    return gameId;
}

public void setGameId(long gameId) {
    this.gameId = gameId;
}

@XmlTransient
public League getLeague() {
    return league;
}

public void setLeague(League league) {
    this.league = league;
}

public boolean isMostFavored() {
    return mostFavored;
}

public void setMostFavored(boolean mostFavored) {
    this.mostFavored = mostFavored;
}

}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Game", propOrder = {
"gameId",
"sport",
"mostFavored"
})
public class Game {

protected long gameId;
 //    @XmlElement(namespace = "http://sdl.ws.lsep.lskings.com/")
protected Sport sport;
protected boolean mostFavored;

/**
 * Gets the value of the gameId property.
 * 
 */
public long getGameId() {
    return gameId;
}

/**
 * Sets the value of the gameId property.
 * 
 */
public void setGameId(long value) {
    this.gameId = value;
}

/**
 * Gets the value of the sport property.
 * 
 * @return
 *     possible object is
 *     {@link Sport }
 *     
 */
public Sport getSport() {
    return sport;
}

/**
 * Sets the value of the sport property.
 * 
 * @param value
 *     allowed object is
 *     {@link Sport }
 *     
 */
public void setSport(Sport value) {
    this.sport = value;
}

/**
 * Gets the value of the mostFavored property.
 * 
 */
public boolean isMostFavored() {
    return mostFavored;
}

/**
 * Sets the value of the mostFavored property.
 * 
 */
public void setMostFavored(boolean value) {
    this.mostFavored = value;
}

}