Re: [ANN] Apache Tomcat 9.0.75 available

2023-05-30 Thread Greg Huber
OK thanks, the device was a mobile, so maybe they were aborts. Would not 
be sending ValueButNoName.



I also had three extra gets/db entries, which cannot happen as I use a 
token, around the same time the exception happened. Strange.


xx.xx.xx.xxx - - [27/May/2023:22:16:35 +0100] "GET /

xx.xx.xx.xxx - - [27/May/2023:22:16:35 +0100] "GET /
xx.xx.xx.xxx - - [27/May/2023:22:16:35 +0100] "GET /
xx.xx.xx.xxx - - [27/May/2023:22:16:40 +0100] "GET /


Cheers

On 29/05/2023 16:52, Mark Thomas wrote:

On 29/05/2023 08:56, Greg Huber wrote:

Hello,

Looking through my logs I am seeing a few:

org.apache.catalina.connector.ClientAbortException: 
java.io.IOException: Broken pipe




Checking previous logs for 9.0.74, there were none, and I have not 
made any changes to my app.  Were there any changes that would cause 
these?


Nothing obvious.

It is AJP so that suggests the proxy is closing the connection before 
Tomcat expects it to. That might happen for a 400 response but to be 
honest, I'd expect the proxy to read the full response before closing 
the connection. There was some tightening up of HTTP request header 
validation that might cause a few more 400 responses but I'd be 
surprised since the proxy should have rejected those requests before 
forwarding them anyway.


The extra checks are for HTTP headers without names. i.e.:

: ValueButNoName

Maybe check if the client is sending such a header?

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

2023-05-30 Thread Mark Thomas

On 30/05/2023 07:17, Lauri wrote:

Hi Mark,

If I understand well:

a) I should remove the commons*.jar files from my 
/u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib.


No. commons-fileupload-1.5.jar (in some form) can stay (see option 1).


b) I do not need to have a specific configuration for Tomcat 10 to use 
servlet-api and jakarta EE packages.


Correct.


I still do not understand the following:

c) Do I use the correct servlet-api jar package ?


Yes.


You answered:
If you are using Tomcat 10, you need to use the Jakarta EE package
names. You can't use the Java EE package names. You can't use any
library that uses the Java EE package names.

But the servlet-api is already included in the Tomcat 10 lib.
What's wrong with this ?


commons-fileupload-1.5.jar uses the Java EE API. It will not work with 
Tomcat 10.



I use these modules in the JSP page:
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="org.apache.commons.fileupload.servlet.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="jakarta.servlet.*" %>
<%@ page import="jakarta.servlet.http.*" %>
<%@ page import="jakarta.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
<%@ page import="org.apache.commons.fileupload.FileItemFactory" %>

What's wrong with this ?


See above.


e) Option 1, 2, 3

The JSP page has not been migrated from Tomcat X to Tomcat 10.
It has been directly deployed in Tomcat 10.

What is wrong in the code of my JSP page ?
Thanks by advance for any indications.


There is nothing wrong with the code in the JSP page but the library you 
are trying to use (commons-fileupload-1.5.jar) will not work with Tomcat 10.


The quickest fix is probably option 1:
Use the Tomcat migration tool for Jakarta EE to convert 
commons-fileupload-1.5.jar from from Java EE to Jakarta EE and then use 
the converted JAR rather than the original.


The best solution is probably the one Thomas pointed out:

Option 4:
Stop using commons-fileupload-1.5.jar and use the methods provided by 
the Servlet API to handle file uploads.


Mark




Kind Regards,

Lauri


From: Mark Thomas 
Sent: Monday, May 29, 2023 5:44 PM
To: users@tomcat.apache.org 
Subject: Re: Cannot upload an image file from a deployed JSP page in Tomcat 10

On 29/05/2023 10:36, Lauri wrote:


  From Tomcat 10 and onwards there has been a move from Java EE to Jakarta EE 
as part of the transfer of Java EE to the Eclipse Foundation, the primary 
package for all implemented APIs has changed from javax.* to jakarta.*.


Note the above.




I have these libraries for the TESTS application:
/u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib:
commons-fileupload-1.5-test-sources.jar
commons-fileupload-1.5-tests.jar
commons-fileupload-1.5-sources.jar
commons-fileupload-1.5-javadoc.jar


You should not have any of the above in your web application.


commons-fileupload-1.5.jar


That library uses the Java EE APIs so it won't work with Tomcat 10 as
you have discovered.


Does someone know if this is related to a bug ?


No. There is no bug.


Do I use the correct servlet-api jar package ?


If you are using Tomcat 10, you need to use the Jakarta EE package
names. You can't use the Java EE package names. You can't use any
library that uses the Java EE package names.


Do Tomcat 10 need to be specifically configured for using servlet-api and 
jakarta EE packages ?


No.


Does someone know what can be the problem ?


See above. You are trying to use a Java EE library with Jakarta EE.


Thanks by advance for any tip(s) and/or suggestion(s).


Option 1.
Write your web application using the Jakarta EE APIs.
Use the Tomcat migration tool for Jakarta EE to convert
commons-fileupload-1.5.jar from from Java EE to Jakarta EE (and any
other libraries using the Java EE APIs).
Deploy your web application with the converted JARs.

Option 2.
Write your web application using the Java EE APIs and then deploy it to
webapps-javaee rather than webapps and Tomcat will use the migration
tool to convert your web application for you.

Option 3.
Write your web application using the Java EE APIs and convert it to
Jkarata EE using the migration tool. Once converted, deploy it to the
webapps directory.

Note: If you use any deprecated Java EE APIs you may still see failures
after conversion as Jakarta EE 10 most of the deprecated APIs.

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



AW: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

2023-05-30 Thread Thomas Hoffmann (Speed4Trade GmbH)
Hello Lauri,

> -Ursprüngliche Nachricht-
> Von: Lauri 
> Gesendet: Dienstag, 30. Mai 2023 08:20
> An: Tomcat Users List 
> Betreff: Re-Cannot upload an image file from a deployed JSP page in Tomcat
> 10
> 
> Hi Thomas,
> 
> I get returned "Page no found" when I navigate through:
> https://www.linuxquestions.org/questions/linux-server-73/fileupload-class-
> 
> I don't understand the relation between the code in my JSP page and the link
> you provided me:
> https://docs.oracle.com/javaee/6/tutorial/doc/gmhba.html
> 
> What do you mean exactly ?
> 
> Thanks by advance for any indications.
> 
> Kind Regards,
> 
> Lauri
> 
> From: Thomas Hoffmann (Speed4Trade GmbH)
> 
> Sent: Monday, May 29, 2023 8:39 PM
> To: Tomcat Users List 
> Subject: AW: Cannot upload an image file from a deployed JSP page in
> Tomcat 10
> 
> Hallo Lauri,
> 
> > -Ursprüngliche Nachricht-
> > Von: Lauri 
> > Gesendet: Montag, 29. Mai 2023 11:36
> > An: users@tomcat.apache.org
> > Betreff: Cannot upload an image file from a deployed JSP page in
> > Tomcat 10
> >
> > 1) Summary of the problem:
> >
> > From Tomcat 10 and onwards there has been a move from Java EE to
> > Jakarta EE as part of the transfer of Java EE to the Eclipse
> > Foundation, the primary package for all implemented APIs has changed
> from javax.* to jakarta.*.
> >
> > I have a JSP page deployed in Tomcat 10 that is intended to upload a
> > file from the desktop (Windows 10) to the server where Tomcat 10 is
> > running (OEL 8).
> > I am unable to upload an image, and I get this error:
> > -
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> > An error occurred at line: [24] in the jsp file: [/index.jsp] The type
> > javax.servlet.http.HttpServletRequest cannot be resolved. It is
> > indirectly referenced from required type
> > org.apache.commons.fileupload.servlet.ServletFileUpload
> > 21: ServletFileUpload upload = new ServletFileUpload(factory);
> > 22:
> > 23: // Parse the request
> > 24: List items = upload.parseRequest(request);
> > 25:
> > 26: // Process the uploaded items
> > 27: Iterator iter = items.iterator();
> > -
> >
> > My application name: TESTS
> > I have these libraries for the TESTS application:
> > /u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib:
> > commons-fileupload-1.5-test-sources.jar
> > commons-fileupload-1.5-tests.jar
> > commons-fileupload-1.5-sources.jar
> > commons-fileupload-1.5-javadoc.jar
> > commons-fileupload-1.5.jar
> >
> > I have in my Tomcat 10 this library:
> > /u01/tomcat/base/middleware/tomcat10/lib:
> > -rw-r--r--. 1 tomcat tomcat 365905 Apr 25 12:16 servlet-api.jar
> >
> > 2) The deployed JSP page:
> >
> > -
> > <%@ page import="org.apache.commons.fileupload.*" %> <%@ page
> > import="org.apache.commons.fileupload.disk.*" %> <%@ page
> > import="org.apache.commons.fileupload.servlet.*" %> <%@ page
> > import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page
> > import="jakarta.servlet.*" %> <%@ page import="jakarta.servlet.http.*"
> > %> <%@ page import="jakarta.sql.*" %> <%@ page import="java.sql.*" %>
> > <%@ page
> > import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
> <%@
> > page import="org.apache.commons.fileupload.FileItemFactory" %>
> >
> > <%
> > // Set the upload directory
> > String uploadDir = "/tmp/";
> >
> > // Create a factory for disk-based file items FileItemFactory factory
> > = new DiskFileItemFactory();
> >
> > // Create a new file upload handler
> > ServletFileUpload upload = new ServletFileUpload(factory);
> >
> > // Parse the request
> > List items = upload.parseRequest(request);
> >
> > // Process the uploaded items
> > Iterator iter = items.iterator(); while (iter.hasNext()) {
> > FileItem item = iter.next();
> >
> > // If the item is a file, save it to the upload directory
> > if (!item.isFormField()) {
> > String fileName = new File(item.getName()).getName();
> > String filePath = uploadDir + fileName;
> > File uploadedFile = new File(filePath);
> > item.write(uploadedFile);
> > }
> > }
> > %>
> > 
> > 
> > File Upload Example  
> > File Upload Example
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -
> >
> > I have found that it looks like:
> > https://www.linuxquestions.org/questions/linux-server-73/fileupload-cl
> > ass- not-working-with-tomcat-10-a-4175710078/
> > But in my situation, it seems to be a different problem.
> >
> > Does someone know if this is related to a bug ?
> > Do I use the correct servlet-api jar package ?
> > Do Tomcat 10 need to be specifically configured for using servlet-api
> > and jakarta EE packages ?
> > Does someone know what can be the problem ?
> >
> > Thanks by advance for any tip(s) and/or suggestion(s).
> 
> I had the same issue because I used internal Tomcat classes.
> In the past the servlet specification didn't have methods to deal with
> multipart uploads.
> Since Servlet 3.0 

Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

2023-05-30 Thread Lauri
Hi Thomas,

I get returned "Page no found" when I navigate through: 
https://www.linuxquestions.org/questions/linux-server-73/fileupload-class-

I don't understand the relation between the code in my JSP page and the link 
you provided me:
https://docs.oracle.com/javaee/6/tutorial/doc/gmhba.html

What do you mean exactly ?

Thanks by advance for any indications.

Kind Regards,

Lauri

From: Thomas Hoffmann (Speed4Trade GmbH) 

Sent: Monday, May 29, 2023 8:39 PM
To: Tomcat Users List 
Subject: AW: Cannot upload an image file from a deployed JSP page in Tomcat 10

Hallo Lauri,

> -Ursprüngliche Nachricht-
> Von: Lauri 
> Gesendet: Montag, 29. Mai 2023 11:36
> An: users@tomcat.apache.org
> Betreff: Cannot upload an image file from a deployed JSP page in Tomcat 10
>
> 1) Summary of the problem:
>
> From Tomcat 10 and onwards there has been a move from Java EE to Jakarta
> EE as part of the transfer of Java EE to the Eclipse Foundation, the primary
> package for all implemented APIs has changed from javax.* to jakarta.*.
>
> I have a JSP page deployed in Tomcat 10 that is intended to upload a file
> from the desktop (Windows 10) to the server where Tomcat 10 is running
> (OEL 8).
> I am unable to upload an image, and I get this error:
> -
> org.apache.jasper.JasperException: Unable to compile class for JSP:
> An error occurred at line: [24] in the jsp file: [/index.jsp] The type
> javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly
> referenced from required type
> org.apache.commons.fileupload.servlet.ServletFileUpload
> 21: ServletFileUpload upload = new ServletFileUpload(factory);
> 22:
> 23: // Parse the request
> 24: List items = upload.parseRequest(request);
> 25:
> 26: // Process the uploaded items
> 27: Iterator iter = items.iterator();
> -
>
> My application name: TESTS
> I have these libraries for the TESTS application:
> /u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib:
> commons-fileupload-1.5-test-sources.jar
> commons-fileupload-1.5-tests.jar
> commons-fileupload-1.5-sources.jar
> commons-fileupload-1.5-javadoc.jar
> commons-fileupload-1.5.jar
>
> I have in my Tomcat 10 this library:
> /u01/tomcat/base/middleware/tomcat10/lib:
> -rw-r--r--. 1 tomcat tomcat 365905 Apr 25 12:16 servlet-api.jar
>
> 2) The deployed JSP page:
>
> -
> <%@ page import="org.apache.commons.fileupload.*" %> <%@ page
> import="org.apache.commons.fileupload.disk.*" %> <%@ page
> import="org.apache.commons.fileupload.servlet.*" %> <%@ page
> import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page
> import="jakarta.servlet.*" %> <%@ page import="jakarta.servlet.http.*" %>
> <%@ page import="jakarta.sql.*" %> <%@ page import="java.sql.*" %>
> <%@ page
> import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %> <%@
> page import="org.apache.commons.fileupload.FileItemFactory" %>
>
> <%
> // Set the upload directory
> String uploadDir = "/tmp/";
>
> // Create a factory for disk-based file items FileItemFactory factory = new
> DiskFileItemFactory();
>
> // Create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(factory);
>
> // Parse the request
> List items = upload.parseRequest(request);
>
> // Process the uploaded items
> Iterator iter = items.iterator(); while (iter.hasNext()) {
> FileItem item = iter.next();
>
> // If the item is a file, save it to the upload directory
> if (!item.isFormField()) {
> String fileName = new File(item.getName()).getName();
> String filePath = uploadDir + fileName;
> File uploadedFile = new File(filePath);
> item.write(uploadedFile);
> }
> }
> %>
> 
> 
> File Upload Example
> 
> 
> File Upload Example
> 
> 
> 
> 
> 
> 
> 
> -
>
> I have found that it looks like:
> https://www.linuxquestions.org/questions/linux-server-73/fileupload-class-
> not-working-with-tomcat-10-a-4175710078/
> But in my situation, it seems to be a different problem.
>
> Does someone know if this is related to a bug ?
> Do I use the correct servlet-api jar package ?
> Do Tomcat 10 need to be specifically configured for using servlet-api and
> jakarta EE packages ?
> Does someone know what can be the problem ?
>
> Thanks by advance for any tip(s) and/or suggestion(s).

I had the same issue because I used internal Tomcat classes.
In the past the servlet specification didn't have methods to deal with 
multipart uploads.
Since Servlet 3.0 there are methods for retrieving the uploads:
https://docs.oracle.com/javaee/6/tutorial/doc/gmhba.html

I replace the ServletFileUpload and used standard methods like getParts().
This worked for me.

Greetings,
Thomas

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

2023-05-30 Thread Lauri
Hi Mark,

If I understand well:

a) I should remove the commons*.jar files from my 
/u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib.
b) I do not need to have a specific configuration for Tomcat 10 to use 
servlet-api and jakarta EE packages.

I still do not understand the following:

c) Do I use the correct servlet-api jar package ?
You answered:
If you are using Tomcat 10, you need to use the Jakarta EE package
names. You can't use the Java EE package names. You can't use any
library that uses the Java EE package names.

But the servlet-api is already included in the Tomcat 10 lib.
What's wrong with this ?

d) Does someone know what can be the problem ?
You answered:
See above. You are trying to use a Java EE library with Jakarta EE.

I use these modules in the JSP page:
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="org.apache.commons.fileupload.servlet.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="jakarta.servlet.*" %>
<%@ page import="jakarta.servlet.http.*" %>
<%@ page import="jakarta.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
<%@ page import="org.apache.commons.fileupload.FileItemFactory" %>

What's wrong with this ?

e) Option 1, 2, 3

The JSP page has not been migrated from Tomcat X to Tomcat 10.
It has been directly deployed in Tomcat 10.

What is wrong in the code of my JSP page ?
Thanks by advance for any indications.

Kind Regards,

Lauri


From: Mark Thomas 
Sent: Monday, May 29, 2023 5:44 PM
To: users@tomcat.apache.org 
Subject: Re: Cannot upload an image file from a deployed JSP page in Tomcat 10

On 29/05/2023 10:36, Lauri wrote:

>  From Tomcat 10 and onwards there has been a move from Java EE to Jakarta EE 
> as part of the transfer of Java EE to the Eclipse Foundation, the primary 
> package for all implemented APIs has changed from javax.* to jakarta.*.

Note the above.



> I have these libraries for the TESTS application:
> /u01/tomcat/base/middleware/tomcat10/webapps/TESTS/WEB-INF/lib:
> commons-fileupload-1.5-test-sources.jar
> commons-fileupload-1.5-tests.jar
> commons-fileupload-1.5-sources.jar
> commons-fileupload-1.5-javadoc.jar

You should not have any of the above in your web application.

> commons-fileupload-1.5.jar

That library uses the Java EE APIs so it won't work with Tomcat 10 as
you have discovered.

> Does someone know if this is related to a bug ?

No. There is no bug.

> Do I use the correct servlet-api jar package ?

If you are using Tomcat 10, you need to use the Jakarta EE package
names. You can't use the Java EE package names. You can't use any
library that uses the Java EE package names.

> Do Tomcat 10 need to be specifically configured for using servlet-api and 
> jakarta EE packages ?

No.

> Does someone know what can be the problem ?

See above. You are trying to use a Java EE library with Jakarta EE.

> Thanks by advance for any tip(s) and/or suggestion(s).

Option 1.
Write your web application using the Jakarta EE APIs.
Use the Tomcat migration tool for Jakarta EE to convert
commons-fileupload-1.5.jar from from Java EE to Jakarta EE (and any
other libraries using the Java EE APIs).
Deploy your web application with the converted JARs.

Option 2.
Write your web application using the Java EE APIs and then deploy it to
webapps-javaee rather than webapps and Tomcat will use the migration
tool to convert your web application for you.

Option 3.
Write your web application using the Java EE APIs and convert it to
Jkarata EE using the migration tool. Once converted, deploy it to the
webapps directory.

Note: If you use any deprecated Java EE APIs you may still see failures
after conversion as Jakarta EE 10 most of the deprecated APIs.

Mark

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org