Xml using StAX: unrecognized property "javax.xml.stream.isInterning"

I am trying to get xml validation using StAXin of our jboss webapp. I read this post and followed suit. Then I saw the following exception:

java.lang.IllegalArgumentException: Source parameter of type javax.xml.transform.stax.StAXSource' is not accepted by this validator. at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source) 

According to this post, the problem was that jboss 5.0.1 has an old version of xerces. So I updated it to 2.11.0, replacing the existing xercesImpl.jar with jboss-5.0.1.GA/lib/endorsed/ . Then jboss will not start due to the following error:

 NoClassDefFoundError: org/w3c/dom/ElementTraversal 

According to this post, in newer versions of xerces, the classes have been split into a separate jar file: xml-apis.jar. I took the latest version of this file (1.4.01, December 2009) from the xerces homepage and added it to jboss-5.0.1.GA//lib/endorsed/ - and now jboss starts fine.

So far so good.

But now I see the following error when I try to call the javax.xml.validation.Validator.validate() method:

 java.lang.IllegalArgumentException: Unrecognized property 'javax.xml.stream.isInterning' 

It seems that SO does not have an existing problem that refers to this property. Of course, I can't be the only person trying to perform XML validation using StAX on jboss 5 ?!

Or am I doing something obviously wrong?

Code snippet:

  Validator validator = requestSchema.newValidator(); StAXSource source = new StAXSource(xmlsr); //an XMLStreamReader validator.validate(source); 
+6
source share
1 answer

We found two solutions to this problem.

One option is to thinly port the XmlStreamReader to a new class, which will ignore the call to getProperty if the parameter is "javax.xml.stream.isInterning" and delegate it otherwise.

Another option is to use an XmlEventReader instead, which is less efficient but works without requiring a special wrapper.

+1
source

Source: https://habr.com/ru/post/982222/


All Articles