W3Schools Learner's Blog

W3Schools Programming knowledge summary website

div

6/20/2018

java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory springmvc

When i started tomcat, springmvc project get "java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory springmvc" error
As follows:
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
 at java.lang.Class.getDeclaredMethods0(Native Method)
 at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
 at java.lang.Class.getDeclaredMethods(Class.java:1975)
 at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:571)
 at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:490)
 at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:474)
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1057)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1030)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
 at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
 at javax.servlet.GenericServlet.init(GenericServlet.java:160)
 at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
 ... 37 more
Solution :
add this commons-fileupload maven jar package to your POM
<dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3.2</version>
</dependency>

1 comment:

Note: only a member of this blog may post a comment.