Grails upload file no signature for method getFile()
file-upload, grails
Solution
By the type in your stack trace, the Spring Security @Secured annotation is wrapping your request in a SecurityContextHolderAwareRequestWrapper. You need to get at the MultipartHttpServletRequest to call getFile I believe.
Also, in your debug Here are params statement, are you seeing the itemImage? If so, I actually think it might be this easy.
def file = params.itemImage
UPDATE: I upvoted the comments. They weren't there when I started typing.
Problem
I am implementing simple form with input fields and file upload. I went over tutorial: http://grails.org/Simple+Avatar+Uploader and documentation: http://grails.org/doc/2.0.x/guide/theWebLayer.html#uploadingFiles However file upload doesn't seem to work! Why is it not working? Any solutions for the problem? Issue: No signature of method: org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [itemImage] Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON(). Stacktrace follows: Message: No signature of method: org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [itemImage] Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON() Line | Method ->> 14 | save in greatoffer.SellController$$EOVmPG4d - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter | 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter | 82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter | 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 918 | run in '' ^ 662 | run . . in java.lang.Thread Main GSP: ``` <g:uploadForm action="save" method="POST"> <fieldset class="form"> <g:render template="form"/> </fieldset> <fieldset class="buttons"> <g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /> </fieldset> </g:uploadForm> ``` Image Upload part of the Form GSP: ``` <label for="images"> <g:message code="item.images.label" default="Images" /> </label> <input type="file" name="itemImage" /> ``` Controller: ``` import grails.plugin.springsecurity.annotation.Secured @Secured('permitAll') class SellController { def index() { render(view: "seller") } def save() { println "Here are params: ${params}"; def f = request.getFile('itemImage') flash.message = message(code: 'default.created.message', args: [message(code: 'item.label', default: 'Item'), params.id]) render(view: "seller") } } ```