FileUpload class not working with Tomcat 10
I've just upgraded to Tomcat 10.0.17 and things mostly seem to work OK. Except, for FileUpload. When I ran one .jsp with the following imports (which worked fine with Tomcat 9.0.41):
Code:
<%@ page import="org.apache.commons.fileupload.*, Code:
org.apache.jasper.JasperException: Unable to compile class for JSP: Next, I dowloaded the latest commons-fileupload 1.4 jarfile. Then changed my imports per the class definition https://tomcat.apache.org/tomcat-10....ileUpload.html to: Code:
<%@ page import="org.apache.tomcat.util.http.fileupload.*, Code:
org.apache.jasper.JasperException: Unable to compile class for JSP: |
Any thoughts on this? I'm currently not able to use the FileUpload class on Tomcat 10.0.17. I'm considering reverting back to 9.0.41. I've explicitly imported javax.servlet.* and javax.servlet.http.*, but I still get:
Code:
An error occurred at line: [231] in the jsp file: [/1099R-Etrans.jsp] More information ... In examining the tomcat 9.0.41 jarfiles I find javax.servlet.http.HttpServletRequest.class in servlet-api.jar. In the 10.0.17 servlet-api.jar there are no javax... classes. There is jakarta/servlet/http/HttpServletRequest.class. There are no javax... classes in any of the 10.0.17 jarfiles. I'm concluding that commons-fileupload-1.4.jar is out of date. I'll look for a more recent version if that's the problem. Can anyone confirm that is the problem and do you know where I could find a jakarta enabled version? Even more information ... According to https://commons.apache.org/proper/commons-fileupload/, version 1.4 is the latest and that was released in 23 December 2018. I've downloaded and examined the source files and they most definitely import javax.servlet.* class. So, it looks like my only recourse is to revert back to Tomcat 9 until the Commons developers get an updated FileUpload class. That version (1.4) has not been updated since 2018. Is FileUploads obsolete? Is there something more recent that has replaced it? |
You're using Tomcat 10 - javax.whatever is now jakarta.whatever
As per the migration notes: Quote:
|
I've done that and pretty much everything works. See my solved thread https://www.linuxquestions.org/quest...ng-4175708886/. Except the FileUpload package which still references javax classes. The Commons fileupload group has no solutions for that. I'm thinking I need to revert back to Tomcat 9 until that package is updated. The most recent version, 1.4, is 3 years old.
|
Quote:
Anyhow, something I've just seen in those migration notes: Quote:
|
boughtonp: I thought I replied to your message earlier, but I don't see it. Maybe I forgot to 'Post'. I had previously downloaded and extracted jakartaee-migration-1.0.0-bin.tar.gz, and ran jakartaee-migration-1.0.0/bin/migrate.sh, which apparently modified some jarfiles, but FileUploads still didn't work.
Anyway, problem solved per my thread https://www.linuxquestions.org/quest...ss-4175710186/. As mentioned, I had been using the org.apache.commons.fileupload package, but the most recent version, 1.4, was released 23 December 2018; certainly before the whole javax -> jakarta thing. So, I changed to using org.apache.tomcat.util.http.fileupload. That above referenced thread shows the imports I needed and a needed call to ServletRequestContext(), but it all now works. I always include some standard imports in all my JSP programs: Code:
<%@ page import="javax.naming.Context, |
My understanding is that there are still a few javax packages in the JVM itself, the javax->jakarta rename only occurred in what was called "Java EE" and is now called "Jakarta EE" - i.e. servlets etc.
|
Quote:
Thanks in advance |
If I could cite a specific source I would have done so, but it is logical since only "Java EE" was affected, so everything else didn't have the legal requirement to change.
I switched from Tomcat to Jetty a while back, and so it the Jetty release announcements mailing list I subscribe to, and when something seems interesting/relevant I search for further information about it - most likely that's where this came from. It's easy to confirm that there are still Java SE classes using the javax namespace, for example see Oracle's Java 17 docs for java.desktop - i.e. the module containing Swing, which still uses javax.swing namespace. |
Quote:
Bottom line is that you did a bit of research and subscribe to a list whereby you collect information. Apparently there is no single place (other than LQ) that tells upgraders what to look out for. In this particular case, figuring it out wasn't hard. I had changed javax.naming, to jakarta.naming and, when that didn't work, I changed it back, and it worked. Thanks again for the info. |
All times are GMT -5. The time now is 05:26 AM. |