开发者

How do I configure JAXB to use Woodstox on JBoss 6?

I'm deploying a Java EE 6 JAX-RS web service on JBoss 6, and I'd like to use Woodstox instead of whatever SAX/StAX parser is currently being used. Since some stack traces list classes in (among other packages):

  • org.apache.xerces.parsers
  • org.apache.xerces.impl
  • org.apache.xerces.jaxp

...I'm guessing that it's using Xerces.

I've tried adding 开发者_JAVA技巧the necessary JARs (woodstox-core-asl-4.1.1.jar and stax2-api-3.1.1.jar) into the EAR (deployed in /lib directory) and also in the WAR (in WEB-INF/lib) but this didn't seem to affect anything, as stack traces from exceptions in XML parsing still reference Xerces packages.

I've already read this question but I think that I've already tried the "add it to your classpath" option as above. I've also already tried adding the following VM args as per this thread:

-Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory
-Djavax.xml.stream.XMLOutputFactory=com.ctc.wstx.stax.WstxOutputFactory
-Djavax.xml.stream.XMLEventFactory=com.ctc.wstx.stax.WstxEventFactory
-Dcom.sun.xml.ws.api.streaming.XMLStreamReaderFactory.woodstox=true
-Dcom.sun.xml.ws.api.streaming.XMLStreamWriterFactory.woodstox=true

What am I doing wrong? How do I get JAXB to use Woodstox instead of (I think) Xerces?


When EclipseLink JAXB (MOXy) creates an XMLStreamReader it does so using the standard APIs, so it should get the one appropriate to your environment:

xmlInputFactory = XMLInputFactory.newInstance();
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(reader);

With that being said, that presupposes that the JBoss JAX-RS implemenation is calling a MOXy code path that allows it to create its own XMLStreamReader (such as unmarshalling an InputStream), and not passing it an actual XMLStreamReader (of JBoss's choosing).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜