Re: File Upload Failure in Struts 7.0.3 Migration - UploadedFilesAware Implementation Issue
Sure, my web.xml looks like this: https://jakarta.ee/xml/ns/jakartaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"; version="6.0"> Struts Blank log4jConfiguration /WEB-INF/classes/log4j2.xml struts2 org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter struts2 /* I forgot also show my struts.xml: https://struts.apache.org/dtds/struts-6.0.dtd";> /index.jsp /success.jsp /error.jsp On the log I can see that I don't have file on my action: El lun, 2 jun 2025 a las 23:44, Zoran Avtarovski () escribió: > Hi Jesus, > > What does your web.xml look like with regards to the struts filters? We > had a similar issue which was resolved by moving to the combined > StrutsPrepareAndExecuteFilter. Sitemesh also played a part in our issue, > but I think by what you are seeing it's worth trying. > > Z. > > On 1/6/2025 6:29 am, Jesus Moreno wrote: > > Hi Lukasz, thanks for your appreciated comments. > > > > I would like to explain in more detail what we have done to try to find > the > > problem and solve it. Here the context: > > > > This is my environment: > > > > - Struts Version: 7.0.3 > > - Java Version: 17 > > - Servlet Container: Apache Tomcat 10.1.36 > > - Key Dependencies (pom): > > - struts2-core:7.0.3 > > - struts2-convention-plugin:7.0.3 > > - struts2-json-plugin:7.0.3 > > - jakarta.servlet-api:5.0.0 > > - log4j-core:2.17.2 > > - Enforced exclusions: javax.servlet:*, javax.activation:* > > > > We've created a basic Maven project (standard archetype) with a simple > file > > upload form containing: > > - 4 regular text fields (working correctly with > > @StrutsParameter(depth=0)) > > - 1 file upload field () > > > > This is my basic jsp: > > > > <%@ page contentType="text/html; charset=UTF-8" %> > > <%@ taglib prefix="s" uri="/struts-tags" %> > > > > > > > > File upload result > > > > > > Hola Mundo desde la tierra... > > > > > > > > > > > > > > > > > > > > > > > > Expected Behavior: > > > > - When implementing UploadedFilesAware, the framework should: > > - Detect multipart requests > > - Process uploaded files through withUploadedFiles(List) > > - Make files available to the action > > > > Where my action looks like: > > > > import org.apache.logging.log4j.LogManager; > > import org.apache.logging.log4j.Logger; > > import org.apache.struts2.ActionSupport; > > import org.apache.struts2.action.UploadedFilesAware; > > import org.apache.struts2.dispatcher.multipart.UploadedFile; > > import org.apache.struts2.interceptor.parameter.StrutsParameter; > > > > public class HelloAction extends ActionSupport implements > > UploadedFilesAware { > > private static final long serialVersionUID = 1L; > > private Logger logger = LogManager.getLogger(HelloAction.class); > > > > private UploadedFile upload; > > private String uploadFileName; > > private String uploadContentType; > > > > @StrutsParameter(depth = 0) > > public String name; > > > > @StrutsParameter(depth = 0) > > public String lastname; > > > > @StrutsParameter(depth = 0) > > public String gender; > > > > @StrutsParameter(depth = 0) > > public String age; > > > > @Override > > public String execute() { > > logger.info("Executing execute method..." + this.uploadFileName); > > return SUCCESS; > > } > > public UploadedFile getUpload() { > > return upload; > > } > > public void setUpload(UploadedFile upload) { > > this.upload = upload; > > } > > public String getUploadFileName() { > > return uploadFileName; > > } > > public void setUploadFileName(String uploadFileName) { > > this.uploadFileName = uploadFileName; > > } > > public String getUploadContentType() { > > return uploadContentType; > > } > > public void setUploadContentType(String uploadContentType) { > > this.uploadContentType = uploadContentType; > > } > > public Logger getLogger() { > > return logger; > > } > > public void setLogger(Logger logger) { > > this.logger = logger; > > } > > public String getName() { > > return name; > > } > > public void setName(String name) { > > this.name = name; > > } > > public String getLastname() { > > return lastname; > > } > > public void setLastname(String lastname) { > > this.lastname = lastname; > > } > > public String getGender() { > > return gender; > > } > > public void setGender(String gender) { > > this.gender = gender; > > } > > public String getAge() { > > return age; > > } > > public void setAge(String age) { > > this.age = age; > > } > > > > @Override > > public void w
Re: File Upload Failure in Struts 7.0.3 Migration - UploadedFilesAware Implementation Issue
Sure, my web.xml looks like this: https://jakarta.ee/xml/ns/jakartaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"; version="6.0"> Struts Blank log4jConfiguration /WEB-INF/classes/log4j2.xml struts2 org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter struts2 /* I forgot also show my struts.xml: https://struts.apache.org/dtds/struts-6.0.dtd";> /index.jsp /success.jsp /error.jsp On the log I can see that I don't have file on my action: 2025-06-03 12:48:20 DEBUG ActionFileUploadInterceptor:200 - Found multipart request: MultiPartRequestWrapper 2025-06-03 12:48:20 DEBUG ActionFileUploadInterceptor:179 - No files have been uploaded/accepted Now I can see is blocked!. I was reading that this message is normal on the log: 2025-06-03 12:48:21 DEBUG DefaultAcceptedPatternsChecker:115 - Sets accepted patterns to [[\w+((\.\w+)|(\[\d+])|(\(\d+\))|(\['(\w-?|[\u4e00-\u9fa5]-?)+'])|(\('(\w-?|[\u4e00-\u9fa5]-?)+'\)))*]], note this impacts the safety of your application! 2025-06-03 12:48:21 DEBUG StrutsUrlEncoder:38 - Using default encoding: UTF-8 2025-06-03 12:48:21 DEBUG SecurityMemberAccess:142 - Checking access for [target: mx.com.struts.action.HelloAction@4489b4fa, member: private org.apache.struts2.dispatcher.multipart.UploadedFile mx.com.struts.action.HelloAction.miLogo, property: miLogo] 2025-06-03 12:48:21 WARN SecurityMemberAccess:174 - Access to non-public [private org.apache.struts2.dispatcher.multipart.UploadedFile mx.com.struts.action.HelloAction.miLogo] is blocked! 2025-06-03 12:48:21 DEBUG InstantiatingNullHandler:106 - Entering nullPropertyValue [target=[mx.com.struts.action.HelloAction@4489b4fa, org.apache.struts2.text.DefaultTextProvider@287a1ff7], property=miLogo] As comment I changed file name as miLogo because I was trying use a different name like upload. Thanks for the support. JMC El lun, 2 jun 2025 a las 23:44, Zoran Avtarovski () escribió: > Hi Jesus, > > What does your web.xml look like with regards to the struts filters? We > had a similar issue which was resolved by moving to the combined > StrutsPrepareAndExecuteFilter. Sitemesh also played a part in our issue, > but I think by what you are seeing it's worth trying. > > Z. > > On 1/6/2025 6:29 am, Jesus Moreno wrote: > > Hi Lukasz, thanks for your appreciated comments. > > > > I would like to explain in more detail what we have done to try to find > the > > problem and solve it. Here the context: > > > > This is my environment: > > > > - Struts Version: 7.0.3 > > - Java Version: 17 > > - Servlet Container: Apache Tomcat 10.1.36 > > - Key Dependencies (pom): > > - struts2-core:7.0.3 > > - struts2-convention-plugin:7.0.3 > > - struts2-json-plugin:7.0.3 > > - jakarta.servlet-api:5.0.0 > > - log4j-core:2.17.2 > > - Enforced exclusions: javax.servlet:*, javax.activation:* > > > > We've created a basic Maven project (standard archetype) with a simple > file > > upload form containing: > > - 4 regular text fields (working correctly with > > @StrutsParameter(depth=0)) > > - 1 file upload field () > > > > This is my basic jsp: > > > > <%@ page contentType="text/html; charset=UTF-8" %> > > <%@ taglib prefix="s" uri="/struts-tags" %> > > > > > > > > File upload result > > > > > > Hola Mundo desde la tierra... > > > > > > > > > > > > > > > > > > > > > > > > Expected Behavior: > > > > - When implementing UploadedFilesAware, the framework should: > > - Detect multipart requests > > - Process uploaded files through withUploadedFiles(List) > > - Make files available to the action > > > > Where my action looks like: > > > > import org.apache.logging.log4j.LogManager; > > import org.apache.logging.log4j.Logger; > > import org.apache.struts2.ActionSupport; > > import org.apache.struts2.action.UploadedFilesAware; > > import org.apache.struts2.dispatcher.multipart.UploadedFile; > > import org.apache.struts2.interceptor.parameter.StrutsParameter; > > > > public class HelloAction extends ActionSupport implements > > UploadedFilesAware { > > private static final long serialVersionUID = 1L; > > private Logger logger = LogManager.getLogger(HelloAction.class); > > > > private UploadedFile upload; > > private String uploadFileName; > > private String uploadContentType; > > > > @StrutsParameter(depth = 0) > > public String name; > > > > @StrutsParameter(depth = 0) > > public String lastname; > > > > @StrutsParameter(depth = 0) > > public String gender; > > > > @StrutsParameter(depth = 0) > > public String age; > > > > @Override > > public String execute() { > > logger.info("Executing ex
Re: File Upload Failure in Struts 7.0.3 Migration - UploadedFilesAware Implementation Issue
Thanks for that. It doesn't look like you have the same issue we did. I wish I could be of more help. I can only suggest start with example app working and then implement your requirements on a step by step basis. In the end that's what helped us identify the issue and get it working. Z. On 4/6/2025 4:56 am, Jesus Moreno wrote: Sure, my web.xml looks like this: https://jakarta.ee/xml/ns/jakartaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"; version="6.0"> Struts Blank log4jConfiguration /WEB-INF/classes/log4j2.xml struts2 org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter struts2 /* I forgot also show my struts.xml: https://struts.apache.org/dtds/struts-6.0.dtd";> /index.jsp /success.jsp /error.jsp On the log I can see that I don't have file on my action: 2025-06-03 12:48:20 DEBUG ActionFileUploadInterceptor:200 - Found multipart request: MultiPartRequestWrapper 2025-06-03 12:48:20 DEBUG ActionFileUploadInterceptor:179 - No files have been uploaded/accepted Now I can see is blocked!. I was reading that this message is normal on the log: 2025-06-03 12:48:21 DEBUG DefaultAcceptedPatternsChecker:115 - Sets accepted patterns to [[\w+((\.\w+)|(\[\d+])|(\(\d+\))|(\['(\w-?|[\u4e00-\u9fa5]-?)+'])|(\('(\w-?|[\u4e00-\u9fa5]-?)+'\)))*]], note this impacts the safety of your application! 2025-06-03 12:48:21 DEBUG StrutsUrlEncoder:38 - Using default encoding: UTF-8 2025-06-03 12:48:21 DEBUG SecurityMemberAccess:142 - Checking access for [target: mx.com.struts.action.HelloAction@4489b4fa, member: private org.apache.struts2.dispatcher.multipart.UploadedFile mx.com.struts.action.HelloAction.miLogo, property: miLogo] 2025-06-03 12:48:21 WARN SecurityMemberAccess:174 - Access to non-public [private org.apache.struts2.dispatcher.multipart.UploadedFile mx.com.struts.action.HelloAction.miLogo] is blocked! 2025-06-03 12:48:21 DEBUG InstantiatingNullHandler:106 - Entering nullPropertyValue [target=[mx.com.struts.action.HelloAction@4489b4fa, org.apache.struts2.text.DefaultTextProvider@287a1ff7], property=miLogo] As comment I changed file name as miLogo because I was trying use a different name like upload. Thanks for the support. JMC El lun, 2 jun 2025 a las 23:44, Zoran Avtarovski () escribió: Hi Jesus, What does your web.xml look like with regards to the struts filters? We had a similar issue which was resolved by moving to the combined StrutsPrepareAndExecuteFilter. Sitemesh also played a part in our issue, but I think by what you are seeing it's worth trying. Z. On 1/6/2025 6:29 am, Jesus Moreno wrote: Hi Lukasz, thanks for your appreciated comments. I would like to explain in more detail what we have done to try to find the problem and solve it. Here the context: This is my environment: - Struts Version: 7.0.3 - Java Version: 17 - Servlet Container: Apache Tomcat 10.1.36 - Key Dependencies (pom): - struts2-core:7.0.3 - struts2-convention-plugin:7.0.3 - struts2-json-plugin:7.0.3 - jakarta.servlet-api:5.0.0 - log4j-core:2.17.2 - Enforced exclusions: javax.servlet:*, javax.activation:* We've created a basic Maven project (standard archetype) with a simple file upload form containing: - 4 regular text fields (working correctly with @StrutsParameter(depth=0)) - 1 file upload field () This is my basic jsp: <%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> File upload result Hola Mundo desde la tierra... Expected Behavior: - When implementing UploadedFilesAware, the framework should: - Detect multipart requests - Process uploaded files through withUploadedFiles(List) - Make files available to the action Where my action looks like: import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.ActionSupport; import org.apache.struts2.action.UploadedFilesAware; import org.apache.struts2.dispatcher.multipart.UploadedFile; import org.apache.struts2.interceptor.parameter.StrutsParameter; public class HelloAction extends ActionSupport implements UploadedFilesAware { private static final long serialVersionUID = 1L; private Logger logger = LogManager.getLogger(HelloAction.class); private UploadedFile upload; private String uploadFileName; private String uploadContentType; @StrutsParameter(depth = 0) public String name; @StrutsParameter(depth = 0) public String lastname; @StrutsParameter(depth = 0) public String gender; @StrutsParameter(depth = 0) public String age; @Override p
Re: File Upload Failure in Struts 7.0.3 Migration - UploadedFilesAware Implementation Issue
Thank you Zoran and I appreciate your assistance, but I believe we are tackling the problem with a very small application, whereas what we actually need is to implement or replace the file upload functionality from version 2.5 to version 7.0.3 in a larger application, where we already have almost 100% of the issues resolved. We just need to fix the file upload problem. We will keep investigating—perhaps we should try the same approach but with an older version of Struts. JMC El mar, 3 jun 2025 a las 19:14, Zoran Avtarovski () escribió: > Thanks for that. > > It doesn't look like you have the same issue we did. I wish I could be > of more help. > > I can only suggest start with example app working and then implement > your requirements on a step by step basis. > > In the end that's what helped us identify the issue and get it working. > > Z. > > > > > On 4/6/2025 4:56 am, Jesus Moreno wrote: > > Sure, my web.xml looks like this: > > > > > > https://jakarta.ee/xml/ns/jakartaee"; > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; > > xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee > > https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"; > > version="6.0"> > > Struts Blank > > > > > > log4jConfiguration > > /WEB-INF/classes/log4j2.xml > > > > > > struts2 > > > > > org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter > > > > > > struts2 > > /* > > > > > > > > I forgot also show my struts.xml: > > > > > > > Configuration 6.0//EN" > > "https://struts.apache.org/dtds/struts-6.0.dtd";> > > > > > > > > > > > >value="false"/> > >value="TRACE"/> > > > >> value="mx.com.struts.action.DebugMultiPartRequest"/> > > > > > > > > > > /index.jsp > > > > > > > >/success.jsp > >/error.jsp > > > > > > > > > > > > > > On the log I can see that I don't have file on my action: > > > > 2025-06-03 12:48:20 DEBUG ActionFileUploadInterceptor:200 - Found > multipart > > request: MultiPartRequestWrapper > > 2025-06-03 12:48:20 DEBUG ActionFileUploadInterceptor:179 - No files have > > been uploaded/accepted > > > > Now I can see is blocked!. I was reading that this message is normal on > the > > log: > > > > 2025-06-03 12:48:21 DEBUG DefaultAcceptedPatternsChecker:115 - Sets > > accepted patterns to > > > [[\w+((\.\w+)|(\[\d+])|(\(\d+\))|(\['(\w-?|[\u4e00-\u9fa5]-?)+'])|(\('(\w-?|[\u4e00-\u9fa5]-?)+'\)))*]], > > note this impacts the safety of your application! > > 2025-06-03 12:48:21 DEBUG StrutsUrlEncoder:38 - Using default encoding: > > UTF-8 > > 2025-06-03 12:48:21 DEBUG SecurityMemberAccess:142 - Checking access for > > [target: mx.com.struts.action.HelloAction@4489b4fa, member: private > > org.apache.struts2.dispatcher.multipart.UploadedFile > > mx.com.struts.action.HelloAction.miLogo, property: miLogo] > > 2025-06-03 12:48:21 WARN SecurityMemberAccess:174 - Access to non-public > > [private org.apache.struts2.dispatcher.multipart.UploadedFile > > mx.com.struts.action.HelloAction.miLogo] is blocked! > > 2025-06-03 12:48:21 DEBUG InstantiatingNullHandler:106 - Entering > > nullPropertyValue [target=[mx.com.struts.action.HelloAction@4489b4fa, > > org.apache.struts2.text.DefaultTextProvider@287a1ff7], property=miLogo] > > > > As comment I changed file name as miLogo because I was trying use a > > different name like upload. > > > > Thanks for the support. > > > > JMC > > > > > > El lun, 2 jun 2025 a las 23:44, Zoran Avtarovski (< > zo...@sparecreative.com>) > > escribió: > > > >> Hi Jesus, > >> > >> What does your web.xml look like with regards to the struts filters? We > >> had a similar issue which was resolved by moving to the combined > >> StrutsPrepareAndExecuteFilter. Sitemesh also played a part in our issue, > >> but I think by what you are seeing it's worth trying. > >> > >> Z. > >> > >> On 1/6/2025 6:29 am, Jesus Moreno wrote: > >>> Hi Lukasz, thanks for your appreciated comments. > >>> > >>> I would like to explain in more detail what we have done to try to find > >> the > >>> problem and solve it. Here the context: > >>> > >>> This is my environment: > >>> > >>> - Struts Version: 7.0.3 > >>> - Java Version: 17 > >>> - Servlet Container: Apache Tomcat 10.1.36 > >>> - Key Dependencies (pom): > >>> - struts2-core:7.0.3 > >>> - struts2-convention-plugin:7.0.3 > >>> - struts2-json-plugin:7.0.3 > >>> - jakarta.servlet-api:5.0.0 > >>> - log4j-core:2.17.2 > >>> - Enforced exclusions: javax.servlet:*, javax.activation:* > >>> > >>> We've created a basic Maven project (standard archetype) with a simple > >> file > >>> upload form containing: > >>> - 4 regular text fields (working correctly with > >>> @StrutsParameter(depth=0)) > >>> - 1 file upload field () > >>> > >>> This is my basic jsp: > >>> > >>> <%@ page contentType="text/html; c