aspose file tools
The moose likes Servlets and the fly likes java.lang.NoSuchMethodError Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "java.lang.NoSuchMethodError" Watch "java.lang.NoSuchMethodError" New topic
Author

java.lang.NoSuchMethodError

Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
I am attepting to use the O'Reilly servlet package to upload files and am receiving the following message:
java.lang.NoSuchMethodError: com.oreilly.servlet.MultipartRequest.(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;ILcom/oreilly/servlet/multipart/FileRenamePolicy V
at UploadTest.doPost(UploadTest.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java:1679)
at com.newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java:1654)
at com.newatlanta.servletexec.ServletExec.standardServletRequest(ServletExec.java:1548)
at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1330)
at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1113)
Any idea what this means?
Christopher Dixon
Greenhorn

Joined: Jan 30, 2002
Posts: 22
A NoSuchMethodError is the runtime equivalent of getting a 'Method not found' error from the compiler.
Any time I've had this problem is was from compiling in one location, and deploying into another.
If the class files in your compiler classpath are up to date, but your runtime isn't, this could happen. Also check the ordering of the elements in the classpath. The classloader may choose any version it happens to run across(How the Java Launcher Finds Classes)
I think that any other types of unresolved method or field calls would result in a more specific exception, like an InvocationTargetException for a bad reflective call or a standard compile error if your binaries were out of date.
HTH,
Chris
Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
Thanks Christopher - I am in fact compiling in one location, and deploying into another. The servlet is being deployed on a host server. The host company has made some upgrades and changes and suddenly I begin to receive this error. I sent them a new jar file and still receive the error. Do you have any recommmendation about what I could tell them to change or if I could change something myself? Forgive my ignorance but I'm new to all of this.
Thanks again for your help!!
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
It looks like the com.oreilly.servlet package is no longer in your classpath. You can try adding it to your own jar, or ask them why the library is not getting found.


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
Wouldn't I get a package can't be found error on the import line if the package wasn't in my classpath?
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
Import statements are only really used as a shortcut for coding/compiling. They're not checked at runtime. per the JLS section:

7.5.1 Single-Type-Import Declaration
...
The compiler keeps track of types by their binary names (�13.1).
...
13.1 The Form of a Binary
...
The class or interface must be named by its binary name, which must meet the following constraints:
The binary name of a top-level type is its canonical name (�6.7).

Assuming the method is static, a static method call might result in your message if the method cannot be resolved.
The other possibility (and on reflection, the more likely) is that a different version of the COS package is on the classpath ahead of the one you compiled against. This would also cause this type of issue.
Yvette Gonzalez
Greenhorn

Joined: Jan 14, 2002
Posts: 9
I am desperate. The server people said that they have the package in the classpath and that there is only one version of it. I also sent them the version I was using to compile and told them to delete anything else. No luck. Still NoSuchMethodError. Is there anything I can do from my end to fix this?
All I need to do is allow the client to upload files. (And yes I double-checked on file permissions as well) Help, help, help!!
I am eternally grateful for any assistance you can lend to a servlet newbie.
Thanks,
Yvette
Chris Smith
Ranch Hand

Joined: May 03, 2002
Posts: 42
Rather than mucking with the classpath in a servlet environment (which is a downright terrible idea), put the JAR file for the COS classes in your WEB-INF/lib directory. Then you're not depending on your web host to make the right libraries and versions accessible.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: java.lang.NoSuchMethodError
 
Similar Threads
i got this error org.apache.struts.config.ForwardConfig.getContextRelative()Z ??
java.security.AccessControlContext error in Thread
problem with calendar display(new to struts) using struts
Servlet RequestDispatcher Problem
java.net.ConnectException: Connection refused: connect