cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <>
Subject Re: @XmlJavaTypeAdapter with HashMap creates two fields on SOAP object
Date Thu, 13 Mar 2008 21:28:12 GMT

If you read the javadoc for the XmlAccessType class, (I just did, I 
didn't realize this either), even private fields will be grabbed if they 
have a JAXB annotation on them. 

Thus, you might want to change to:
to only look at the field.

Alternatively, take the @XmlJavaTypeAdapter annotation off the field and 
stick it on the getter.   Thus, the field won't have any jaxb 
annotations on it.   JAXB SHOULD allow it to work that way.


On Thursday 13 March 2008, cwilkes wrote:
> One of my WebParams has a HashMap in it and so I've annotated the
> field with @XmlJavaTypeAdapter and created an XmlAdapter for it.  The
> java generated from the WSDL has a field that's listed in that Adapter
> along with a "HashMap" that extends "AbstractMap", both in my
> namespace.
> The "HashMap" object has getters and setters based on the fieldName
> while the holder object for a List of my Entries is based on the
> method name. That is this class:
> @XmlRootElement
> public class AdRequest {
>   @XmlJavaTypeAdapter(QueryParametersAdapter.class)
>   private Map<String, String[]> m_queryParameters;
>   public Map<String, String[]> getQueryParameters() { ... }
>   public void setQueryParameters(Map<String, String[]>
> p_queryParameters) {} }
> Turns into this after wsdl2java:
> public class AdRequest  implements {
>     private mynamespace.HashMap m_queryParameters;
>     private mynamespace.AdRequestQueryParametersEntry[]
> queryParameters; }
> Where mynamespace.HashMap extends mynamespace.AbstractMap.
> Marshalling and unmarshalling works fine with my Map<String,String[]>
> values added via setQueryParameters(AdRequestQueryParametersEntry[]). 
> I'm just annoyed that this HashMap shows up.
> I've tried to annotate with XmlAccessType set to PUBLIC_MEMBER (the
> default) and PROPERTY but it hasn't helped me out.
> If I change the field name in my original AdRequest to
> "queryParameters" I get this error in my logs:
> Class has two properties of the same name "queryParameters"
> 	this problem is related to the following location:
> 		at public java.util.Map
> com.ladro.cxf.image.AdRequest.getQueryParameters() at
> com.ladro.cxf.image.AdRequest
> 	this problem is related to the following location:
> 		at private java.util.Map
> com.ladro.cxf.image.AdRequest.queryParameters at
> com.ladro.cxf.image.AdRequest
> which does make sense.
> Has anyone else seen this?  I've also tried marking the field as
> XmlTransient but then JAXB ignores the getters and setters.

J. Daniel Kulp
Principal Engineer, IONA

View raw message