-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Annotation to prevent jackson to use JAXB annotations! #11
Comments
You are aware that it is possible to avoid use of JAXB annotations by not registering |
My initial offer was wrong. Sorry. Same time, I want jackson have special annotation to honor jaxb annotation (if somebody likes it). @JacksonHonorJaxbAnnotations
@XmlRootElement
class X {
@XmlElement(name = "description")
String summary
} As Java EE developer I control my components only, not container configurations. My customers want to deploy my components in any Java EE container. They expect, my components will produce valid XML and JSON data all the time, not only when they break down the JAXBAnnotationsIntrospector in their apps servers. Now I have 2 ways
Dear jackson developers! You have done GREAT job! You have Excellent set of Json annotations! Let me use it to configure JSON format on the same entity where I use Jaxb annotations to configure XML format. Please, please, please!!!! |
@SamSoldatenko Jackson does not support JAXB annotations by default. Optional support can be enabled using this module: https://github.com/FasterXML/jackson-module-jaxb-annotations/ and specifically registering with:
Now: since you are having the issue, I suspect you are using Jackson via a framework that does enable JAXB annotation support by default. If so, it would be good to figure out a way to either prevent registration. If this is not feasible, it should still be possible to reset annotation introspection settings with
(or just create new, plain I hope this helps. |
Wow!!! Thank you, very much! |
I deleted jackson-module-jaxb-annotations from wildfly configuration. And now first call to my API generates HTTP 500!
Second and subsequent calls works well. Lets GO back to point!
Can you please deprecate JaxbAnnotationIntrospector and never use JaxB annotations to format JSON? |
Temporary workaround: import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector
import groovy.transform.CompileStatic
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import javax.ws.rs.ext.ContextResolver
import javax.ws.rs.ext.Provider
@CompileStatic
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonContextResolver implements ContextResolver<ObjectMapper> {
private ObjectMapper objectMapper;
public JacksonContextResolver() throws Exception {
this.objectMapper = new ObjectMapper()
this.objectMapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector())
}
public ObjectMapper getContext(Class<?> objectType) {
return objectMapper;
}
} This jackson libs is required to compile.
|
No. I'm sorry but this makes no sense. It was added specifically because many others DO want to use JAXB annotations due to various reasons. If you do not want it, don't add it; if you are using a framework, work with their developers to get voice heard. |
Annotation to completely prevent jackson from using JAXB annotations!
see http://stackoverflow.com/questions/5005668/configure-jersey-jackson-to-not-use-xmlelement-field-annotation-for-json-field/5008595
Should produce
The text was updated successfully, but these errors were encountered: