This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NoSuchMethodError  RSS feed

 
Yvette Gonzalez
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yvette Gonzalez
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!