请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

【upload.do】504 (剧终,解决办法看下面我的最新一条评论)

系统: ubuntu
catalina.out:

[16:44:10.992][INFO][com.mmall.service.impl.FileServiceImpl][http-bio-8080-exec-8] 开始上传文件,上传文件的文件名:111.png,上传的路径:/developer/apache-tomcat-7.0.73/webapps/ROOT/upload,新文件名:08e4647d-089b-4b86-b10c-9db920bd9399.png
[16:44:10.996][INFO][com.mmall.util.FTPUtil][http-bio-8080-exec-8] 开始连接ftp服务器
[16:46:21.683][ERROR][com.mmall.util.FTPUtil][http-bio-8080-exec-8] 上传文件异常
java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.7.0_80]
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) ~[na:1.7.0_80]
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) ~[na:1.7.0_80]
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) ~[na:1.7.0_80]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.7.0_80]
        at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_80]
        at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:762) ~[commons-net-3.1.jar:3.1]
        at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:565) ~[commons-net-3.1.jar:3.1]
        at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:557) ~[commons-net-3.1.jar:3.1]
        at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1795) ~[commons-net-3.1.jar:3.1]
        at com.mmall.util.FTPUtil.uploadFile(FTPUtil.java:51) [classes/:na]
        at com.mmall.util.FTPUtil.uploadFile(FTPUtil.java:32) [classes/:na]
        at com.mmall.service.impl.FileServiceImpl.upload(FileServiceImpl.java:45) [classes/:na]
        at com.mmall.controller.backend.ProductManageController.upload(ProductManageController.java:130) [classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80]
        at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) [servlet-api.jar:na]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807) [spring-webmvc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) [servlet-api.jar:na]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.73]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.73]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.73]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.73]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.73]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.73]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.73]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) [catalina.jar:7.0.73]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.73]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) [catalina.jar:7.0.73]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) [catalina.jar:7.0.73]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.73]
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958) [catalina.jar:7.0.73]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.73]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) [catalina.jar:7.0.73]
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) [tomcat-coyote.jar:7.0.73]
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) [tomcat-coyote.jar:7.0.73]
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.73]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.73]
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:579)
        at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:762)
        at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:565)
        at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:557)
        at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1795)
        at com.mmall.util.FTPUtil.uploadFile(FTPUtil.java:51)
        at com.mmall.util.FTPUtil.uploadFile(FTPUtil.java:32)
        at com.mmall.service.impl.FileServiceImpl.upload(FileServiceImpl.java:45)
        at com.mmall.controller.backend.ProductManageController.upload(ProductManageController.java:130)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
[16:46:21.685][INFO][com.mmall.util.FTPUtil][http-bio-8080-exec-8] 开始连接ftp服务器,结束上传,上传结果:{}

vsftpd.log:

Sun Apr 26 16:44:11 2020 [pid 1662] CONNECT: Client "::ffff:182.**.**.**"
Sun Apr 26 16:44:11 2020 [pid 1661] [sammy] OK LOGIN: Client "::ffff:182.**.**.**"

备注:我创建ftp用户文件的方式跟课程中的不一样,是以下面的方式创建的
How To Set Up vsftpd for a User’s Directory on Ubuntu 18.04
并且我用终端ftp命令上传文件没有问题(只是需要进入下一级目录files/ , 默认进入的目录是没有写权限的)

调试:

  1. 我加了一行logger
    图片描述
    日志文件:
    图片描述
    这就说明就是图片中最后一行代码的问题!

我的ftp用户和文件夹是这样创建了:
用户:useadd sammy -d /product/sammy/ftpfile/ -s /usr/sbin
ftpfile: 没有写权限 chmod a-w ftpfile/
files: 在ftpfile/ 下创建子目录 files ,并改变用户(组) chown -R sammy:sammy files/
每次上传文件,登录之后需要进入 files 文件夹才可以进行上传操作

正在回答 回答被采纳积分+3

13回答

提问者 williamdsy 2020-04-27 17:08:51
注意:之前的我发的评论的方法和方向都是错误的,之所以无法上传文件是因为 云服务...
登录后可查看完整回答登录/注册
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信