Re: [FileUpload] "final" DiskFileItem breaks code on upgrade to v2

Mark Thomas <[email protected]> Sat, 14 Jun 2025 11:49:56 +0100
Newsgroups gmane.comp.jakarta.commons.user
Message-ID <[email protected]>
On 13/06/2025 21:13, Joel Griffith wrote:
> To add to my last post, I ran `crimson.jar` through the migration tool by
> itself, calling the output `crimson-jakarta.jar`.
> 
> After replacing `crimson.jar` with it and deploying (to webapps-javaee/
> still), I get the same error as my last message:
> ```
> 13-Jun-2025 15:54:34.030 SEVERE [ajp-nio-0.0.0.0-8009-exec-1]
> org.apache.tomcat.util.digester.Digester.getParser Error creating SAX parser
>          javax.xml.parsers.ParserConfigurationException: Feature:
> http://apache.org/xml/features/allow-java-encodings
>                  at
> org.apache.crimson.jaxp.SAXParserFactoryImpl.newSAXParser(SAXParserFactoryImpl.java:119)
>                  at
> org.apache.tomcat.util.digester.Digester.getParser(Digester.java:695)
>                  at
> org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:867)
>                  at
> org.apache.tomcat.util.digester.Digester.parse(Digester.java:1539)
> ...
> ```
> including the `javax.xml.parsers.ParserConfigurationException` part.
> 
> If I examine the migrated JAR, it still uses the 'javax' namespace
> internally:
> ```
> $ jar -tf crimson-jakarta.jar | grep "javax"
> META-INF/services/javax.xml.parsers.DocumentBuilderFactory
> META-INF/services/javax.xml.parsers.SAXParserFactory
> 
> $ jar -tf crimson-jakarta.jar | grep "jakarta"
> {no output}
> ```
> 
> I might not understand the nature of the migration tools you've suggested.
> Are they not intended to perform this conversion, or am I misusing them?

No, you are seeing a different issue. The XML parser in the web 
application is being registered for use JVM wide but it isn't visible to 
the entire JVM since it is part of the web application.

Possible solutions include:
- Just remove the JAR. Chances are your web application will work fine 
with the JVM provided parser these days.
- Move crimson.jar from WEB-INF/lib to Tomcat's $CATALINA_BASE/lib 
directory.

HTH,

Mark