How to make Eclipelink moxy marshal HashMap <String, String>?

I get the following exception when a method in a jersey application returns a HashMap

[Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: Exception [EclipseLink-25007] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor for class java.util.HashMap was not found in the project.  For JAXB, if the JAXBContext was bootstrapped using TypeMappingInfo[] you must call a marshal method that accepts TypeMappingInfo as an input parameter.]

This method:

@PUT
@Path("/subscriptions/{id}")
@Produces("application/json")
public Map<String, String> updateSubscription(@PathParam("id") int id) {
  Map<String, String> response = new HashMap<String, String>();
  response.put("status", "ok");
  return response;
}

Moxy works well with POJO in my application. So, I guess it is smart enough to handle a HashMap.

+4
source share
1 answer

Note. I am EclipseLink JAXB (MOXy) and a member of JAXB (JSR-222) .

MOXyJsonProvider Map. EclipseLink 2.5.2 2.6.0, isReadable/isWriteable false , MOXy JSON- . , 11 2013 :

, Map:

+5

All Articles