In MOXy, you can specify how jsonProvider should do its job for JAXB.
So, when you do JAX-RS, add the following code to your class obtained from the application
I used this code on Tomcat 7 with good results. (eclipselink 2.4.1)
@ApplicationPath("/rest") public class RestApplication extends Application { ... public Set< Object> getSingletons() { HashSet<Object> set = new HashSet<Object>(1); set.add( newMoxyJsonProvider()); return set; } public static MOXyJsonProvider newMoxyJsonProvider() { MOXyJsonProvider result = new MOXyJsonProvider();
In Glassfish 3.1.2 and WAS 8.5, however, newMoxyJsonProvider () is not required, but then the JAXB provider is configured by the server. In the case of Glassfish, which comes with MOXy, I saw the same problems with null values. I have not tested it yet, but guess that the answer is to configure JAXB at the application server level, if at all possible.
Jan Serneels Mar 05 '13 at 10:52 2013-03-05 10:52
source share