Hello, I am planning to migrate my Struts 1 App to Struts 2. I have a page where I am uploading files to the server. I tried to follow the fileupload sample that comes with the Struts 2 distribution but without success.
In my app, I have all the required .jar files in the WEb-INF/lib directory. You can find the parts related to the fileupload below. It seems I am missing some kind of "converters" that would identify that the property upload in my form is of type "file". Thanks for your help. -Karthik. struts.xml file --------------- <action name="TestStruts2FileUpload" class="com.breezeware.action.TestStruts2FileUploadAction" method="upload" > <interceptor-ref name="fileUpload"/> <interceptor-ref name="basicStack"/> <result name="input">/tiles_jsp/dash_board.jsp</result> <result>/tiles_jsp/dash_board.jsp</result> </action> ---------------------------------------------------- action file: ----------- public class TestStruts2FileUploadAction extends ActionSupport { private String contentType; private File upload; private String fileName; public String getUploadFileName() { return fileName; } public void setUploadFileName(String fileName) { this.fileName = fileName; System.out.println("File name = " + fileName); } public String getUploadContentType() { return contentType; } public void setUploadContentType(String contentType) { this.contentType = contentType; System.out.println("File content type= " + contentType); } public File getUpload() { return upload; } public void setUpload(File upload) { this.upload = upload; } public String input() throws Exception { return SUCCESS; } public String upload() throws Exception { return SUCCESS; } } --------------------------------------------------- FileUpload.jsp page: <form action="/PLM/struts2/TestStruts2FileUpload.action" method="post" type="multipart/form-data"> File 'upload' = <input type="file" name="upload" /> <input type="submit" /> </form> ------------------------------------------------ I am using JBOSS in my application server. When I try tp upload the file, following exception is thrown (as seen in JBOSS log). 2007-04-05 12:15:53,512 DEBUG [com.opensymphony.xwork2.DefaultActionProxy] Creating an DefaultActionProxy for namespace /struts2 and action name TestStruts2FileUpload 2007-04-05 12:15:53,513 DEBUG [com.opensymphony.xwork2.interceptor.ParametersInterceptor] Setting params upload => [ cmk2.jpg ] 2007-04-05 12:15:53,516 DEBUG [com.opensymphony.xwork2.util.XWorkConverter] Property: upload 2007-04-05 12:15:53,516 DEBUG [com.opensymphony.xwork2.util.XWorkConverter] Class: com.breezeware.action.TestStruts2FileUploadAction 2007-04-05 12:15:53,524 DEBUG [com.opensymphony.xwork2.util.XWorkConverter] converter is null for property upload. Mapping size: 0 2007-04-05 12:15:53,524 DEBUG [com.opensymphony.xwork2.util.XWorkConverter] field-level type converter for property [upload] = none found 2007-04-05 12:15:53,524 DEBUG [com.opensymphony.xwork2.util.XWorkConverter] global-level type converter for property [upload] = none found 2007-04-05 12:15:53,524 DEBUG [com.opensymphony.xwork2.util.XWorkConverter] falling back to default type converter [EMAIL PROTECTED] 2007-04-05 12:15:53,529 DEBUG [com.opensymphony.xwork2.util.OgnlValueStack] Error setting value ognl.MethodFailedException: Method "setUpload" failed for object [EMAIL PROTECTED] [java.lang.NoSuchMethodException: setUpload([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:964) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131) at com.opensymphony.xwork2.util.OgnlValueStack$ObjectAccessor.setProperty(OgnlValueStack.java:68) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656) at com.opensymphony.xwork2.util.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:44) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476)..................... --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]