1

I have very simple NetBean Project. It include this controlller line,

    @RequestMapping(value = "/MyDoc.htm", method = RequestMethod.POST)
    public String FormUpload(@RequestParam("file") MultipartFile file)  {        
       return "MyDoc";
    }

and in dispatcher servelet I have,

<bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="50000000"/>

But I am getting this error java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory

The project include just a single controller with two methods. GET and POST. GET version works very fine.

Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322

1 Answers1

2

It looks like one of the packages you are using has a dependency on one of the apache commons software packages. You can either add it to your classpath manually, or use a build tool like maven, ant, ivy etc.

thatidiotguy
  • 8,701
  • 13
  • 60
  • 105
  • how to do that? Can you please explain. I am very new. – Imran Qadir Baksh - Baloch Jan 27 '12 at 18:18
  • Look at the answer above mine for some pictures. I am not familiar with net beans but it would have something to do configuring your build path. You can download the apache commons package you need at their website commons.apache.org – thatidiotguy Jan 27 '12 at 18:19
  • @FahimParkar or thatidiotguy, I am now getting, java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream. Can you please help again – Imran Qadir Baksh - Baloch Jan 27 '12 at 18:35
  • 1
    Once again you are just missing a package that is needed. Go to the same site and download the apache commons io package and then include it on your build path, and make sure it is in your class path at runtime. – thatidiotguy Jan 27 '12 at 18:37
  • 1
    The exception means that a class that is needed cannot be found. You will see the name of the class in the exception detail. Classes are loaded from the classpath defined for your application, that might be via a command line parameter classpath or CLASSPATH environment variable. So, determine the class you need, find out where it is - a JAR file or directory - and make sure that the classpath includes that jar file. – Fahim Parkar Jan 27 '12 at 18:40
  • @Fahim You just got no love in this thread huh? All your answers were way better than mine lol – thatidiotguy Jan 27 '12 at 18:42