Hi,
How to resolve exception:
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
Full stack trace of the exception:
May 01, 2016 1:04:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Spring4Example' did not find a matching property. May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/8.0.28 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Oct 7 2015 18:25:21 UTC May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 8.0.28.0 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Windows 7 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 6.1 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: x86 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\java8\jdk8\jre May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.8.0_05-b13 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: D: \roseindiavideotutorials2015\workspace\.metadata\.plugins \org.eclipse.wst.server.core\tmp0 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: D:\roseindiavideotutorials2015\apache- tomcat-8.0.28 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=D: \roseindiavideotutorials2015\workspace\.metadata\.plugins \org.eclipse.wst.server.core\tmp0 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=D: \roseindiavideotutorials2015\apache-tomcat-8.0.28 May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dwtp.deploy=D: \roseindiavideotutorials2015\workspace\.metadata\.plugins \org.eclipse.wst.server.core\tmp0\wtpwebapps May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.endorsed.dirs=D: \roseindiavideotutorials2015\apache-tomcat-8.0.28\endorsed May 01, 2016 1:04:04 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dfile.encoding=Cp1252 May 01, 2016 1:04:04 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\java8\jdk8\jre\bin;C:\Windows\Sun\Java\bin;C: \Windows\system32;C: \Windows;C:/java8/jdk8/jre/bin/client;C:/java8/jdk8/jre/bin;C:/java8/jdk8/j re/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows \System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0:C: \Program Files\Java\jdk1.7.0_25\bin;D:\recorder\ffmpeg-latest-win32- static\bin;C:\Program Files\sox-14-4-1;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\sox-14-4-1\;C:\Program Files \TortoiseSVN\bin;C:\sbt-0.13.9\sbt\bin;C:\Program Files\scala\bin; C: \Program Files\scala\bin;C:\Maven\apache-maven-3.3.9\bin;C:\Windows \system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows \System32\WindowsPowerShell\v1.0:C:\Program Files\Java \jdk1.7.0_25\bin;D:\recorder\ffmpeg-latest-win32-static\bin;C:\Program Files\sox-14-4-1;C:\Program Files\MySQL\MySQL Server 5.1\bin;C: \Program Files\sox-14-4-1\;C:\Program Files\TortoiseSVN\bin;C:\sbt- 0.13.9\sbt\bin;C:\Program Files\scala\bin; C:\Program Files\scala\bin;C: \Maven\apache-maven-3.3.9\bin;C:\java8\jdk8\sdk\bin;D: \roseindiavideotutorials2015\eclipse;;. May 01, 2016 1:04:04 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-8080"] May 01, 2016 1:04:04 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read May 01, 2016 1:04:04 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-nio-8009"] May 01, 2016 1:04:04 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read May 01, 2016 1:04:04 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 500 ms May 01, 2016 1:04:04 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina May 01, 2016 1:04:04 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/8.0.28 May 01, 2016 1:04:05 PM org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. May 01, 2016 1:04:05 PM org.apache.catalina.core.ApplicationContext log INFO: No Spring WebApplicationInitializer types detected on classpath May 01, 2016 1:04:05 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'dispatcher' May 01, 2016 1:04:05 PM org.springframework.web.servlet.DispatcherServlet initServletBean INFO: FrameworkServlet 'dispatcher': initialization started May 01, 2016 1:04:05 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh INFO: Refreshing WebApplicationContext for namespace 'dispatcher- servlet': startup date [Sun May 01 13:04:05 IST 2016]; root of context hierarchy May 01, 2016 1:04:05 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml] May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/helloworld],methods=[],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView net.roseindia.controllers.HelloWorldController.helloWord() May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/loginform.html],methods=[GET],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.LoginController.showForm(java.util.Map) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/loginform.html],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.LoginController.processForm (net.roseindia.form.LoginForm,org.springframework.validation.BindingRes ult,java.util.Map) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/registrationform.html],methods=[GET],params= [],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.RegistrationController.showRegistration (java.util.Map) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/registrationform.html],methods=[POST],params= [],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.RegistrationController.processRegistration (net.roseindia.form.Registration,org.springframework.validation.BindingRe sult) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/formoutput.html],methods=[POST],params= [],headers=[],consumes=[],produces=[],custom=[]}" onto public void net.roseindia.controllers.SimpleFormController.simple (net.roseindia.form.User,org.springframework.ui.Model) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/simpleForm.html],methods=[GET],params= [],headers=[],consumes=[],produces=[],custom=[]}" onto public void net.roseindia.controllers.SimpleFormController.simpleForm (org.springframework.ui.Model) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/uploadfile],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.UploadFileController.create (net.roseindia.form.UploadItem,org.springframework.validation.BindingRe sult,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRes ponse,javax.servlet.http.HttpSession) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/uploadfile],methods=[GET],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.UploadFileController.getUploadForm (org.springframework.ui.Model) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/uploadfileindex],methods=[GET],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.UploadFileIndexController.showRegistration (java.util.Map) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/uploadfileindex],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.UploadFileIndexController.processRegistration (org.springframework.validation.BindingResult) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/validationform.html],methods=[GET],params= [],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.ValidationController.showValidatinForm (java.util.Map) May 01, 2016 1:04:06 PM org.springframework.web.servlet.mvc.method.annotation.RequestMapping HandlerMapping registerHandlerMethod INFO: Mapped "{[/validationform.html],methods=[POST],params= [],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String net.roseindia.controllers.ValidationController.processValidatinForm (net.roseindia.form.ValidationForm,org.springframework.validation.Bindin gResult,java.util.Map) May 01, 2016 1:04:06 PM org.hibernate.validator.internal.util.Version <clinit> INFO: HV000001: Hibernate Validator 5.2.4.Final May 01, 2016 1:04:06 PM org.apache.catalina.core.ApplicationContext log SEVERE: StandardWrapper.Throwable java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getDeclaredConstructors(Unknown Source) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPo stProcessor.determineCandidateConstructors (AutowiredAnnotationBeanPostProcessor.java:234) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.determineConstructorsFromBeanPostProcessors (AbstractAutowireCapableBeanFactory.java:1040) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:1013) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory $1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g etSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preI nstantiateSingletons(DefaultListableBeanFactory.java:703) at org.springframework.context.support.AbstractApplicationContext.finishBea nFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:482) at org.springframework.web.servlet.FrameworkServlet.configureAndRefresh WebApplicationContext(FrameworkServlet.java:658) at org.springframework.web.servlet.FrameworkServlet.createWebApplication Context(FrameworkServlet.java:624) at org.springframework.web.servlet.FrameworkServlet.createWebApplication Context(FrameworkServlet.java:672) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationCo ntext(FrameworkServlet.java:543) at org.springframework.web.servlet.FrameworkServlet.initServletBean (FrameworkServlet.java:484) at org.springframework.web.servlet.HttpServletBean.init (HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet (StandardWrapper.java:1231) at org.apache.catalina.core.StandardWrapper.loadServlet (StandardWrapper.java:1144) at org.apache.catalina.core.StandardWrapper.load (StandardWrapper.java:1031) at org.apache.catalina.core.StandardContext.loadOnStartup (StandardContext.java:4923) at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5215) at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker (Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory at org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1333) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1167) ... 34 more May 01, 2016 1:04:06 PM org.apache.catalina.core.StandardContext loadOnStartup SEVERE: Servlet [dispatcher] in web application [/Spring4Example] threw load() exception java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory at org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1333) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1167) at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getDeclaredConstructors(Unknown Source) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPo stProcessor.determineCandidateConstructors (AutowiredAnnotationBeanPostProcessor.java:234) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.determineConstructorsFromBeanPostProcessors (AbstractAutowireCapableBeanFactory.java:1040) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:1013) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory $1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g etSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preI nstantiateSingletons(DefaultListableBeanFactory.java:703) at org.springframework.context.support.AbstractApplicationContext.finishBea nFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:482) at org.springframework.web.servlet.FrameworkServlet.configureAndRefresh WebApplicationContext(FrameworkServlet.java:658) at org.springframework.web.servlet.FrameworkServlet.createWebApplication Context(FrameworkServlet.java:624) at org.springframework.web.servlet.FrameworkServlet.createWebApplication Context(FrameworkServlet.java:672) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationCo ntext(FrameworkServlet.java:543) at org.springframework.web.servlet.FrameworkServlet.initServletBean (FrameworkServlet.java:484) at org.springframework.web.servlet.HttpServletBean.init (HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet (StandardWrapper.java:1231) at org.apache.catalina.core.StandardWrapper.loadServlet (StandardWrapper.java:1144) at org.apache.catalina.core.StandardWrapper.load (StandardWrapper.java:1031) at org.apache.catalina.core.StandardContext.loadOnStartup (StandardContext.java:4923) at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5215) at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker (Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source) at java.lang.Thread.run(Unknown Source) May 01, 2016 1:04:06 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-nio-8080"] May 01, 2016 1:04:06 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-nio-8009"] May 01, 2016 1:04:06 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 2674 ms
Hi,
Add following dependency in your project to resolve the error:
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency>
Thanks
Check following Video:
Thanks
Ads