Hi,
Am trying to follow
http://jersey.java.net/nonav/documentation/latest/json.html#json.jaxb.approach.section
On my first attempt I was told that no ObjectFactory or jaxb.index file
exists. So following a suggestion on StackOverflow I added a
maven-antrun-plugin to my POM which generated my jaxb.index file (there are
quite a few models with JAXB annotations).
However, the problem persists. Perhaps a classpath issue, but I've not
found any examples to follow to investigate and fix.
The root of my problem here is that I am building a project for deployment
in either Glassfish or JBoss. Under testing we found the JSON
representations using shipped defaults differed making testing impossible.
I was advised to check the JSON Processing spec mailing list by the London
JUG for advice on overcoming this, but was told there's nothing in the
pipeline and to ask here instead.
So in short I am trying to specify JSON.NATURAL across both Glassfish and
JBoss, beginning with the link above and still not getting far.
Some help and insight would be appreciated.
Here's my Provider:
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JAXBContextResolver implements ContextResolver<JAXBContext> {
private JAXBContext context;
public JAXBContextResolver() throws JAXBException {
System.out.println("Creating a custom JAXBContextResolver");
this.context = new
JSONJAXBContext(JSONConfiguration.natural().build(),
com.example.model.Account.class.getPackage().getName());
System.out.println("Created a custom JAXBContextResolver");
}
@Override
public JAXBContext getContext(Class<?> type) {
System.out.println("Servicing context request for type " +
type.getSimpleName());
return this.context;
}
}
James