Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4
-
None
-
Unknown
Description
I have a jaxrs service configured as follows:
<util:map id="jsonNamespaceMap" map-class="java.util.Hashtable"> <entry key="http://acme.com/aegis/customtypes" value="t"/> <entry key="http://acme.com/v1/activities" value="a"/> <entry key="http://model.v1.acme.com" value="m"/> </util:map> <jaxrs:server id="restServer" address="/rest"> <jaxrs:serviceBeans> <ref bean="bookstoreService" /> </jaxrs:serviceBeans> <jaxrs:providers> <bean class="org.apache.cxf.jaxrs.provider.AegisJSONProvider"> <property name="namespaceMap" ref="jsonNamespaceMap"/> </bean> </jaxrs:providers> </jaxrs:server>
I then have a JSON payload for my service request:
{ "m.details": { "m.date": "2011-08-05", "m.updates": [ { "a.value": { "t.string": { "t.name": "My String", "t.value": "myValue" } } } ] } }
However, the object parameter to the service method is not correctly populated with the value of date, or updates, and the logs contain messages such as:
WARNING: xsi:type absent, and no type available for m.date
A bit of digging around, and it seems to me the problem is at line 142 of AegisJSONProvider (and yes, I dislike the namespace map concept as much as the person that added comments at line 140 of AegisJSONProvider!):
namespaceMap.put(typeToRead.getSchemaType().getNamespaceURI(), "ns1");
I believe that put here should be switched to putIfAbsent - what is happening is that on initialisation, the namespace map correctly contains the 3 entries as per the spring config, but when the message is processed, typeToRead is not null, and the configured namespace prefix, {{m}}is overwritten with ns1.