Why do you have two sets of square brackets around your collection?
Chris
On Wed, Aug 18, 2010 at 8:48 AM, Jonathan Cook - FM&T
<Jonathan.Cook2_at_bbc.co.uk> wrote:
> These are my beans if that helps:
>
> @XmlRootElement
> public class ConfigurationItemList {
>
> private String sport;
> private String module;
>
> private List<ConfigurationItem> configurationItemList;
>
> public ConfigurationItemList(){}
>
> public ConfigurationItemList(List<ConfigurationItem>
> configurationItemList,
> String sport, String module){
> this.configurationItemList = configurationItemList;
> this.sport = sport;
> this.module = module;
> }
>
> public List<ConfigurationItem> getConfigurationItemList() {
> return configurationItemList;
> }
>
> public void setConfigurationItemList(
> List<ConfigurationItem> configurationItemList) {
> this.configurationItemList = configurationItemList;
> }
>
> public String getSport() {
> return sport;
> }
>
> public void setSport(String sport) {
> this.sport = sport;
> }
>
> public String getModule() {
> return module;
> }
>
> public void setModule(String module) {
> this.module = module;
> }
>
> }
>
> @XmlRootElement
> public class ConfigurationItem {
>
> private String key;
> private String value;
>
> public ConfigurationItem() {
> }
>
> public ConfigurationItem(Configuration config) {
> key = config.getId().getKey();
> value = config.getValue();
> }
>
> public String getKey() {
> return key;
> }
>
> public void setKey(String key) {
> this.key = key;
> }
>
> public String getValue() {
> return value;
> }
>
> public void setValue(String value) {
> this.value = value;
> }
> }
>
> Thanks for any help.
>
> _____________________________________________
> From: Jonathan Cook - FM&T
> Sent: 18 August 2010 16:43
> To: 'users_at_jersey.dev.java.net'
> Subject: FW: JaxB Problem
>
> Sent this to the wrong list. Sorry.
>
> Hi,
>
> I'm using Jax-B and sending in a Json request as follows:
>
> @POST
> @Consumes("application/json")
> @Produces("application/json")
> @Path("property")
> public Response createOrUpdateConfiguration(ConfigurationItemList
> configItemListRequest){
> //log.debug(updateJson);
> log.debug(configItemListRequest.getModule());
> }
>
> This throws an error:
> java.lang.IllegalArgumentException: local part cannot be "null" when
> creating a QName
> at javax.xml.namespace.QName.<init>(QName.java:246)
> at javax.xml.namespace.QName.<init>(QName.java:299)
> at
> com.sun.jersey.json.impl.reader.EndElementEvent.<init>(EndElementEvent.java:51)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.generateEEEvent(JsonXmlStreamReader.java:694)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStreamReader.java:371)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStreamReader.java:166)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.next(JsonXmlStreamReader.java:429)
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:175)
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:333)
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:312)
> at
> com.sun.jersey.json.impl.JSONUnmarshaller.unmarshal(JSONUnmarshaller.java:100)
>
> The json I am sending in is valid json:
> {
> "configurationItemList": [
> [
> {
> "key": "name",
> "value": "dsf"
> },
> {
> "key": "title",
> "value": "sdf"
> },
> {
> "key": "titlelink",
> "value": "sdf"
> }
> ]
> ],
> "module": "twitter",
> "sport": "winterolympics"
> }
>
> ConfigurationItemList contains a list of ConfigurationItems which represent
> the key value pairs. I'm not sure what is going wrong. I wondered if there
> was a bug in the version of jersey I am using 1.0.3? Or maybe the array of
> key value pairs needs to be structured differently so it has a name?
>
> If I change to just submitting a string into the POST method then it comes
> in no problem.
>
> Thanks
> Jon