On Wed, Oct 18, 2023 at 1:36 PM mlic...@gmail.com <mlich...@gmail.com> wrote: > > I do have Woodstox JAR loaded as well. Running things in a Karaf container. > Guess my question is more about how to avoid this randomness of service > lookup that sometimes Jackson receives a Stax implementation that is not > capable of writing XML.
Hmmmh. Yes, that is unfortunate. If so, maybe there is explicit inclusion of SJSXP (Sun/Oracle stax implementation), or ancient reference implementation. But you can (and may need to) construct Jackson `XmlFactory` with Woodstox XMLInputFactory (WstxInputFactory) and XMLOutputFactory (WstxOutputFactory). -+ Tatu +- > > On Wednesday, October 11, 2023 at 11:01:33 PM UTC+2 Tatu Saloranta wrote: >> >> On Wed, Oct 11, 2023 at 12:29 AM mlic...@gmail.com <mlic...@gmail.com> wrote: >> > >> > Hi >> > I have this issue occur randomly and wonder how Jackson binds to an XML >> > writer? >> >> By default underlying Stax implementation to use is detected using >> Java platform SPI interface. >> If you do not include specific implementation it will probably use one >> bundled with JDK which is not >> as full-featured, reliable or efficient as Woodstox (or Aalto XML). >> >> I would recommend adding dependency to Woodstox: >> >> https://mvnrepository.com/artifact/com.fasterxml.woodstox/woodstox-core >> >> and things will work better. >> >> Otherwise it is possible that pretty-printing fails as you have seen. >> Problem is that with Stax implementations that do not implement Stax2 >> extensions (like one bundled with JDK) it is not possible to use >> certain write methods. >> This is unfortunate flaw in handling which tries to work around the >> missing Stax2 api but cannot handle all cases. >> >> -+ Tatu +- >> >> > Caused by: java.lang.UnsupportedOperationException: Not implemented >> > >> > at >> > org.codehaus.stax2.ri.Stax2WriterAdapter.writeRaw(Stax2WriterAdapter.java:419) >> > ~[!/:4.2.1] >> > >> > at >> > org.codehaus.stax2.ri.Stax2WriterAdapter.writeRaw(Stax2WriterAdapter.java:411) >> > ~[!/:4.2.1] >> > >> > at >> > com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter$Lf2SpacesIndenter.writeIndentation(DefaultXmlPrettyPrinter.java:532) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter.writeLeafElement(DefaultXmlPrettyPrinter.java:271) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.writeString(ToXmlGenerator.java:663) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.databind.ser.std.StringSerializer.serialize(StringSerializer.java:41) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:733) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.dataformat.xml.ser.XmlBeanSerializerBase.serializeFields(XmlBeanSerializerBase.java:212) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.dataformat.xml.ser.XmlBeanSerializer.serialize(XmlBeanSerializer.java:129) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.dataformat.xml.ser.XmlSerializerProvider.serializeValue(XmlSerializerProvider.java:108) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4624) >> > ~[!/:2.14.3] >> > >> > at >> > com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3869) >> > ~[!/:2.14.3] >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "jackson-user" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to jackson-user...@googlegroups.com. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msgid/jackson-user/9993cf25-a59a-44ae-84cf-3646bcfe50bdn%40googlegroups.com. > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to jackson-user+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jackson-user/21e94482-1cd9-45b8-bf7a-e5cdbeaed693n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CAGrxA25c9SpcnR70az0m0PsAgWkMAJ%3DokpjHMitejPms%2BSEGvA%40mail.gmail.com.