文件上传问题

  本地测试的时候是没问题的,上传到线上会报错;

java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class com.jfinal.upload.MultipartRequest
	at com.jfinal.aop.Invocation.invoke(Invocation.java:107) ~[jfinal-4.2.jar:?]
	at cn.api.interceptor.MyExceptionInterceptor.intercept(MyExceptionInterceptor.java:23) [api-0.0.1-SNAPSHOT.jar:?]
	at com.jfinal.aop.Invocation.invoke(Invocation.java:91) [jfinal-4.2.jar:?]
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82) [jfinal-4.2.jar:?]
	at cn.api.handler.BaseJsonHandler.handle(BaseJsonHandler.java:19) [api-0.0.1-SNAPSHOT.jar:?]
	at com.jfinal.plugin.druid.DruidStatViewHandler.handle(DruidStatViewHandler.java:81) [jfinal-4.2.jar:?]
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89) [jfinal-4.2.jar:?]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104) [undertow-servlet-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830) [undertow-core-2.0.19.Final.jar:2.0.19.Final]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_201]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_201]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.jfinal.upload.MultipartRequest
	at com.jfinal.core.Controller.getFiles(Controller.java:846) ~[jfinal-4.2.jar:?]
	at cn.api.controller.UploadController.index(UploadController.java:36) ~[api-0.0.1-SNAPSHOT.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at com.jfinal.aop.Invocation.invoke(Invocation.java:97) ~[jfinal-4.2.jar:?]


  线上环境:windows Server 2012 + java8

相关上传代码:

String file_path = new SimpleDateFormat("yyyyMMdd").format(new Date()) + "/"; //文件上一层保存路径
getFiles(file_path); //异常代码的地方
UploadFile uploadFile = getFile();


评论区

杜福忠

2019-06-12 10:01

java.lang.NoClassDefFoundError: Could not initialize class com.jfinal.upload.MultipartRequest
cos的那个jar没有加上

xiaoming1234

2019-06-12 10:08

@杜福忠 多谢。maven 打包的时候,外部的lib包没打包进来。应该是这个原因。

热门反馈

扫码入社