Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

@XmlList as @XmlValue Field on @XmlRoot Element Class Generates Invalid Method Signature #55

Open
glassfishrobot opened this issue Nov 29, 2012 · 5 comments

Comments

@glassfishrobot
Copy link
Contributor

I have a simple wrapper class that contains a field named "items" which is a Collection of simple types. Using the @xmllist annotation I get a nice space-delimited String of values. Placing @XmlValue annotation on that field allows the class to be referenced from another class as an @XmlAttribute.

@XmlType
@XmlRootElement
public class ListOnly {

	@XmlList
	@XmlValue
	List<String> items = new ArrayList<String>();
}

Notice I also place the @XmlRootElement on the class so I may use it as a return type from a JAX-RS Resource:

@GET
	@Path("list/{ITEMS}")
	@Produces(MediaType.APPLICATION_XML)
	public ListOnly getList(@PathParam("ITEMS") ListOnly list){
		return list;
	}

Running wadl-client-plugin I receive a compile error since the resulting method name is also the return type of String[].

public String[] getAsString[]() {
UriBuilder localUriBuilder = _uriBuilder.clone();
WebResource resource = _client.resource(localUriBuilder.buildFromMap(_templateAndMatrixParameterValues));
WebResource.Builder resourceBuilder = resource.getRequestBuilder();
resourceBuilder = resourceBuilder.accept("application/xml");
return resourceBuilder.method("GET", String[].class);
            }

Notice the method name includes illegal characters [].

I don't think I was expecting String[] to be the return type anyway. It seems the return type should simply be String since the formatted XmlList results in a single String. Changing the return type would also bypass the naming problem if that is appropriate.

The work-around is to remove the @XmlValue annotation which disallows the class' use as an XmlAttribute.

Environment

maven wadl-client-plugin 1.1.2.1
Mac OSX Mountain Lion

Affected Versions

[1.1.2]

@glassfishrobot
Copy link
Contributor Author

Reported by aroller

@glassfishrobot
Copy link
Contributor Author

File: ListOnly.java
Attached By: aroller

@glassfishrobot
Copy link
Contributor Author

File: SandboxWebApi.java
Attached By: aroller

@glassfishrobot
Copy link
Contributor Author

File: SandboxWebApi.java
Attached By: aroller

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA WADL-55

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants