Java.lang.NoSuchMethodError when downloading a file

I am developing an application that has an image loading module. I wrote the following code to get data with multiple forms.

List items = servletFileUpload.parseRequest (request);

I am using commons-fileupload-1.2.1.jar for this purpose. When I deploy my assembly to the jboss-5.1.0.GA server, it throws an error when loading any file. The error is as follows:

java.lang.NoSuchMethodError: org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest (Lorg / Apache / Common / FileUpload / RequestContext;) Ljava / Util / List; at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest (ServletFileUpload.java:126) at com.bworld.action.UploadSubscriptionImage.processRequest (UploadSubscriptionImage.java:46) at com.bworld.action.UploadSubscription .java: 145) in javax.servlet.http.HttpServlet.service (HttpServlet.java:637) in javax.servlet.http.HttpServlet.service (HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain. internalDoFilter (ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter (ReplyHeaderFilter at .apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:206) at org.apache.catalina.core.Standar dWrapperValve.invoke (StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke () at org.jboss.web.tomcat.security.JaccContextValve.invoke (JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process (SecurityContextEstablishmentValve.java:b6cat) .security.SecurityContextEstablishmentValve.invoke (SecurityContextEstablishValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportalalvevevealvealvealvealvealvealvealvealvealvealvealvealvealvealvealvealvealvealve ) on org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke (CachedConnectionValve.java:158) on org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:109) on org .apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter. (Http11Protocol.javaPoint98) at org.apache.tomcat.util.net.JIoEndpoint $ Worker.run (JIoEndpoint.java:447) in java.lang.Thread.run (Thread.java:679)

Can someone tell me how to recover from this problem?

+4
source share
4 answers

You are using the wrong jar. Your class path refers to something other than what you think. Check your Jboss lib and classpath for jars with a similar name but with different versions. Then do a full cleanup + build cycle, delete the jboss tmp directory, and clean up + publish to the server. Here is another SO answer

+1
source

Your Commons file is missing from your WEB-INF / lib folder or it has already been sent by JBoss, and you should not duplicate it in WEB-INF / lib

Related: http://techblog.bozho.net/?p=866

+1
source

I know this is an old question, but my answer may help someone, this may be the reason due to several reasons

  • Commons file-upload jar may not be in your WEB-INF / lib folder mentioned by Bonzho.
  • Commons file-upload comes with the latest tomcat and jboss servers, so you do not need to use this jar externally in your project. but let's say you used it, then you can try to remove it from the class path and do a clean build, which is likely to work
  • but sometimes you can still get the java.lang.NoSuchMethodError error message: this can happen because eclipse does not show an error for older import data coming from the database you are using, and you go through the project classes and make sure that import is either import org.apache.tomcat.util.http.fileupload.* or import org.apache.commons.fileupload* not both

It is always useful to use pom.

0
source

use the public version 1.3.3. I used and solved this

0
source

Source: https://habr.com/ru/post/1414895/


All Articles