I wrote a webservice that has some data model classes and I'm using JAXB to generate the XML from those classes in the responses. Initially the model classes were part of the webservice project and included in the war in the WEB-INF/classes directory. I want to be able to reuse the model classes for my client code, so I refactored them out into a separate project that builds a jar that the webservice project now depends on.
Initially I had a jaxb.properties file in my war project classpath which I moved it to the jar file project as well. It has this entry:
I'm deploying to Glassfish v3 which is supposed to use EclipseLink as its JAXB implementation by default.
The problem is when I deploy the war with the model classes jar, I get this exception:
- with linked exception:
It doesn't seem to matter if I have a jaxb.properties file in my classpath or not (I've added it to the war, jar and neither).
I'm using Maven so my initial war pom.xml had this dependency:
The jaxb.properties file should be included with and in the same package as the domain classes.
By default GlassFish uses the Metro JAXB implemention, Metro is the JAXB reference implementation. GlassFish contains EclipseLink's core and JPA components, but does not yet include the MOXy and SDO components. However you can add the MOXy bundle yourself from:
Unfortunately, currently the JAX-WS implementation in GlassFish is hard coded to use the Metro JAXB implementation. Once you solve your current configuration issue, you will get to the point where you see a ClassCastException from the JAX-WS layer when you try to use MOXy JAXB.
Alternatively MOXy can be used as the binding layer with Jersey (JAX-RS) in GlassFish. For an example see:
So, when it was working with the model classes as part of the war project, it must have been using Metro JAXB? Nothing against MOXy, but if I don't need to add it to Glassfish and can use Metro instead I think that's the way I'd like to go just because it's less configuration. Is there a compelling reason to use MOXy?