0

The tag name of an element is suppose to be "default" ie. but I can't use default as a variable name for obvious reasons.

The Problem is, when I try to annotate any class Params' field. I get 500 Error Code.

Uncommenting the @XmlElement(name="default") on private String defaultx; in the Param class causes the web service call to return Error 500. There is no stack trace on the exception so I can't figure out why this would be happening especially when @XmlElement(name="ErrCode") in the USSDDynMenuResponse class does cause any problems

USSDDynMenuResponse.java

@XmlRootElement(name="USSDDynMenuResponse")
public class USSDDynMenuResponse {
    public USSDDynMenuResponse() {
        this.dataSet = new DataSet();
    }

    private String requestId;
    private String sessionId;
    private String msisdn;
    private String starCode;
    private String langId;
    private String encodingScheme;
    private String transferCode;

    private DataSet dataSet;

    @XmlElement(name="ErrCode")
    private String ErrCode;
    private String errURL;
    private String timeStamp;

    public String getRequestId() {
        return requestId;
    }...

Param.java

public class Param {
    public Param() {
        this.tagSet = new TagSet();
    }

    public Param(String id, String value) {
        this.tagSet = new TagSet();
        this.id = id;
        this.value = value;
    }

    private String id;
    private String value;
    private String index;
    private String accessString;
    private String rspTag;
    private String rspFlag;
    private String rspURL;
    private String appendIndex;

    //@XmlElement(name="default")
    private String defaultx;
    private TagSet tagSet;

    public String getId() {
        return id;
    }...

DataSet.java

public class DataSet {
    public DataSet() {
        param = new ArrayList<>();
        param.clear();
    }

    private List<Param> param;

    public List<Param> getParam() {
        return this.param;
    }

    public void setParam(List<Param> param) {
        this.param = param;
    }
}
rnxfod
  • 907
  • 2
  • 8
  • 14
  • There must be an exception somewhere. You server software may swallow it but it is definitely thrown - otherwise there would be no problem. Find it and post it. If you can't find it, build an isolated [MCVE](http://stackoverflow.com/help/mcve). – lexicore Apr 13 '18 at 17:23
  • I also don't see where `Param` is used in `USSDDynMenuResponse` – lexicore Apr 13 '18 at 17:24
  • apologies Param is variable in DataSet, I've included that too – rnxfod Apr 14 '18 at 10:17
  • Does not really look suspicious to me. Try creating a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). If it fails because of JAXB, it should be reproducible with JAXB alone. And search for the exception. – lexicore Apr 14 '18 at 10:19
  • thanks lexicore wrapped my return statement in a try catch which brought out the exception stack trace I needed. Turns out inner class of the the xml root have to be annotated with **@XmlAccessorType(XmlAccessType.FIELD)**, not sure why no documentation or tutorial mentions this. https://stackoverflow.com/questions/14057932/javax-xml-bind-jaxbexception-class-nor-any-of-its-super-class-is-known-to-t – rnxfod Apr 14 '18 at 13:40

0 Answers0