使用commons-fileupload时启动报错

问题描述

使用commons-fileupload时启动报错

使用commons-fileupload时启动报java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory错误,最开始都是可以使用的,后来改了下配置文件的配置就开始报错,生成的target目录下是有那个配置文件的

在maven已经导入了commons-fileupload包:

 <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
</dependency>

在spring配置文件中配置:

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

项目启动时报了如下异常:
2016-05-24 10:30:56.492 [RMI TCP Connection(3)-127.0.0.1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_77]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_77]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_77]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:609) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:521) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:507) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1069) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068) [catalina.jar:7.0.68]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584) [catalina.jar:7.0.68]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:7.0.68]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) [catalina.jar:7.0.68]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) [catalina.jar:7.0.68]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) [catalina.jar:7.0.68]
五月 24, 2016 10:30:56 上午 org.apache.catalina.core.StandardContext startInternal
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1859) [catalina.jar:7.0.68]
严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) [tomcat-coyote.jar:7.0.68]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:na]
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_77]
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618) [catalina.jar:7.0.68]
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565) [catalina.jar:7.0.68]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) [tomcat-coyote.jar:7.0.68]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:na]
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_77]
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_77]
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_77]
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_77]
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_77]
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) [na:na]
at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:na]
at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:na]
at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_77]
at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:na]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) [na:na]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) [na:na]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) [na:na]
at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_77]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) [na:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_77]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_77]
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1858) ~[catalina.jar:7.0.68]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701) ~[catalina.jar:7.0.68]
... 73 common frames omitted

解决方案

NoClassDefFoundError说明没有正确引入包,把包文件拷贝到web目录下的lib目录内,并在项目设置中关联一下。

解决方案二:

在maven中配置没起效,把jar包复制到lib目录下就可以了

时间: 2024-10-03 13:07:11

使用commons-fileupload时启动报错的相关文章

javaweb-在ssh 中 用ServletActionContext获取session时启动报错

问题描述 在ssh 中 用ServletActionContext获取session时启动报错 ServletActionContext.getRequest().getSession(); 怎么才能在启动的时候就有ServletActionContext,而不用在ActionSupport处理请求时在获取 解决方案 是报空指针吗? 没有请求时 ServletActionContext.getRequest() 为null 解决方案二: http://blog.csdn.net/suncaoyo

nexus bundle方式安装时启动报错

本地下载 bundle方式的 nexus,启动时,报错:the nexus service was launched,but failed to start.如下图: 需要修改NEXUS_HOME\bin\jsw\conf\wrapper.conf 配置文件, 如此之后,可正常启动nexus. 查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

jsp-weblogic启动报错,在tomcat部署没问题

问题描述 weblogic启动报错,在tomcat部署没问题 但是我本地没有把axis2 war包里的jsp复制到项目中去,只是复制了war包里web-inf下的配置文件并和spring集成. 到了weblogic就出问题了 解决方案 Weblogic启动报错Tomcat部署项目时启动报错总结weblogic 部署ejb报错 解决方案二: weblogic要比tomcat严格 报错信息粘出来看看

weblogic部署时fckeditor报错,tomcat下正常

问题描述 weblogic部署时fckeditor报错,tomcat下正常 解决方案 Tomcat部署项目时启动报错总结tomcat 部署项目时的报错(一)实现webservice客户端后在tomcat下运行正常,部署到weblogic报错

求助!tomcat启动正常,访问javaweb时控制台报错

问题描述 求助!tomcat启动正常,访问javaweb时控制台报错 访问javaweb项目时报错,在myeclise6.0上无该异常,在myeclise10上报如下异常:org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet jsp threw exceptionjavax.xml.parsers.FactoryConfigurationError: Provider org.a

ssh整合-spring整合hibernate做测试时没有报错,当三个整合时启动就报错啦,求大神指点!!

问题描述 spring整合hibernate做测试时没有报错,当三个整合时启动就报错啦,求大神指点!! 报的错误org.springframework.scheduling.quartz.JobMethodInvocationFailedException: Invocation of method 'ecsUnsigned' on target class [class $Proxy17] failed; nested exception is org.springframework.tran

ssh-项目启动时c3p0报错 求大神

问题描述 项目启动时c3p0报错 求大神 com.mchange.v2.async.ThreadPoolAsynchronousRunner]com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@179d578 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! [com.mchange.v2.async.T

vsftpd启动报错

sftpd 启动 报错: vsftpd:500 OOPS: bad bool value in config file for: anonymous_enable sftpd 启动 报错: vsftpd:500 OOPS: bad bool value in config file for: anonymous_enable 处理办法:vi /etc/vsftpd.conf 时,:每行的值都不要有空格,否则启动时会出现错误,举个例子, 假如我在listen=YES后多了个空格,那我启动时就出现.

急,关于项目启动报错的问题

问题描述 急,关于项目启动报错的问题 是这样的,有a,b两个分项目,b项目是主项目然后在myeclipse中b项目build path引入了a项目然后b的类中可以引入a的类,直接在java文件最上面写import就行,但是b的spring.xml无法读取到a项目的spring.xml等xml文件(就是在b的xml中import的a的xml无法连接到)启动时报错,报找不到那个a的xml的错误 解决方案 Spring MVC项目启动报错信息__待解决关于项目启动报错一些新手问题weblogic启动项