我正在尝试运行一个应用程序,它将列出ftp服务器中的所有文件。程序在本地机器上运行良好,但在部署到aws时出错。
26-Apr-2021 16:16:17.519 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [DropShippingApplication] appears to have started a thread named [scheduling-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@11.0.9/java.net.SocketInputStream.socketRead0(Native Method)
java.base@11.0.9/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
java.base@11.0.9/java.net.SocketInputStream.read(SocketInputStream.java:168)
java.base@11.0.9/java.net.SocketInputStream.read(SocketInputStream.java:140)
java.base@11.0.9/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
java.base@11.0.9/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
java.base@11.0.9/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
java.base@11.0.9/java.io.InputStreamReader.read(InputStreamReader.java:185)
java.base@11.0.9/java.io.BufferedReader.fill(BufferedReader.java:161)
java.base@11.0.9/java.io.BufferedReader.read(BufferedReader.java:182)
org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58)
org.apache.commons.net.ftp.FTP.__getReply(FTP.java:321)
org.apache.commons.net.ftp.FTP.__getReply(FTP.java:300)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:523)
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:847)
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:785)
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3409)
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3339)
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:3016)
com.motionFashion.DropShippingApplication.JobScheduler.Schedular.copyFileFromFTPtoAWS_v2(Schedular.java:95)
com.motionFashion.DropShippingApplication.JobScheduler.Schedular.performDailyTask(Schedular.java:61)
java.base@11.0.9/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base@11.0.9/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base@11.0.9/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base@11.0.9/java.lang.reflect.Method.invoke(Method.java:566)
org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
java.base@11.0.9/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
java.base@11.0.9/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
java.base@11.0.9/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
java.base@11.0.9/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base@11.0.9/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base@11.0.9/java.lang.Thread.run(Thread.java:834)
26-Apr-2021 16:16:17.549 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
26-Apr-2021 16:16:17.590 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
26-Apr-2021 16:16:20.803 INFO [mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385)
at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1038)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:117)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:84)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
2021-04-26 16:16:22
Full thread dump OpenJDK 64-Bit Server VM (11.0.9+11-LTS mixed mode, sharing):
Threads class SMR info:
_java_thread_list=0x00007f3444090ab0, length=13, elements={
0x00007f3474051000, 0x00007f3474053000, 0x00007f3474059000, 0x00007f347405b800,
0x00007f347405d800, 0x00007f347405f800, 0x00007f34740a3800, 0x00007f34740a7000,
0x00007f34740ef000, 0x00007f3474114000, 0x00007f3475ab7800, 0x00005618fef93800,
0x00007f3474016000
}
"Reference Handler" #2 daemon prio=10 os_prio=0 cpu=2.80ms elapsed=2265.69s tid=0x00007f3474051000 nid=0x4967 waiting on condition [0x00007f3479e24000]
java.lang.Thread.State: RUNNABLE
at java.lang.ref.Reference.waitForReferencePendingList(java.base@11.0.9/Native Method)
at java.lang.ref.Reference.processPendingReferences(java.base@11.0.9/Reference.java:241)
at java.lang.ref.Reference$ReferenceHandler.run(java.base@11.0.9/Reference.java:213)
"Finalizer" #3 daemon prio=8 os_prio=0 cpu=0.84ms elapsed=2265.69s tid=0x00007f3474053000 nid=0x4968 in Object.wait() [0x00007f3479d23000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.9/Native Method)
- waiting on <no object reference available>
at java.lang.ref.ReferenceQueue.remove(java.base@11.0.9/ReferenceQueue.java:155)
- waiting to re-lock in wait() <0x00000000d55c78f0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(java.base@11.0.9/ReferenceQueue.java:176)
at java.lang.ref.Finalizer$FinalizerThread.run(java.base@11.0.9/Finalizer.java:170)
"Signal Dispatcher" #4 daemon prio=9 os_prio=0 cpu=0.07ms elapsed=2265.69s tid=0x00007f3474059000 nid=0x4969 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 cpu=17943.32ms elapsed=2265.69s tid=0x00007f347405b800 nid=0x496a waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
No compile task
"C1 CompilerThread0" #6 daemon prio=9 os_prio=0 cpu=4378.68ms elapsed=2265.69s tid=0x00007f347405d800 nid=0x496b waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
No compile task
"Sweeper thread" #7 daemon prio=9 os_prio=0 cpu=471.47ms elapsed=2265.68s tid=0x00007f347405f800 nid=0x496c runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Common-Cleaner" #8 daemon prio=8 os_prio=0 cpu=3.35ms elapsed=2265.64s tid=0x00007f34740a3800 nid=0x496d in Object.wait() [0x00007f347981e000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.9/Native Method)
- waiting on <no object reference available>
at java.lang.ref.ReferenceQueue.remove(java.base@11.0.9/ReferenceQueue.java:155)
- waiting to re-lock in wait() <0x00000000d55c7f68> (a java.lang.ref.ReferenceQueue$Lock)
at jdk.internal.ref.CleanerImpl.run(java.base@11.0.9/CleanerImpl.java:148)
at java.lang.Thread.run(java.base@11.0.9/Thread.java:834)
"Service Thread" #9 daemon prio=9 os_prio=0 cpu=0.05ms elapsed=2265.62s tid=0x00007f34740a7000 nid=0x496e runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"AsyncFileHandlerWriter-1706234378" #12 daemon prio=5 os_prio=0 cpu=134.94ms elapsed=2265.56s tid=0x00007f34740ef000 nid=0x4970 waiting on condition [0x00007f34790c0000]
java.lang.Thread.State: TIMED_WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@11.0.9/Native Method)
- parking to wait for <0x00000000d55c82b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(java.base@11.0.9/LockSupport.java:234)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(java.base@11.0.9/AbstractQueuedSynchronizer.java:2123)
at java.util.concurrent.LinkedBlockingDeque.pollFirst(java.base@11.0.9/LinkedBlockingDeque.java:513)
at java.util.concurrent.LinkedBlockingDeque.poll(java.base@11.0.9/LinkedBlockingDeque.java:675)
at org.apache.juli.AsyncFileHandler$LoggerThread.run(AsyncFileHandler.java:159)
"FileHandlerLogFilesCleaner-1" #13 daemon prio=5 os_prio=0 cpu=20.71ms elapsed=2265.48s tid=0x00007f3474114000 nid=0x4971 waiting on condition [0x00007f3478fbf000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@11.0.9/Native Method)
- parking to wait for <0x00000000d55c84d0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(java.base@11.0.9/LockSupport.java:194)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@11.0.9/AbstractQueuedSynchronizer.java:2081)
at java.util.concurrent.LinkedBlockingQueue.take(java.base@11.0.9/LinkedBlockingQueue.java:433)
at java.util.concurrent.ThreadPoolExecutor.getTask(java.base@11.0.9/ThreadPoolExecutor.java:1054)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.9/ThreadPoolExecutor.java:1114)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.9/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.9/Thread.java:834)
"scheduling-1" #19 prio=5 os_prio=0 cpu=224.68ms elapsed=2243.34s tid=0x00007f3475ab7800 nid=0x4979 runnable [0x00007f343bcfc000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(java.base@11.0.9/Native Method)
at java.net.SocketInputStream.socketRead(java.base@11.0.9/SocketInputStream.java:115)
at java.net.SocketInputStream.read(java.base@11.0.9/SocketInputStream.java:168)
at java.net.SocketInputStream.read(java.base@11.0.9/SocketInputStream.java:140)
at sun.nio.cs.StreamDecoder.readBytes(java.base@11.0.9/StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(java.base@11.0.9/StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(java.base@11.0.9/StreamDecoder.java:178)
- locked <0x00000000c64f8f40> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(java.base@11.0.9/InputStreamReader.java:185)
at java.io.BufferedReader.fill(java.base@11.0.9/BufferedReader.java:161)
at java.io.BufferedReader.read(java.base@11.0.9/BufferedReader.java:182)
- locked <0x00000000c64f8f40> (a java.io.InputStreamReader)
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58)
- locked <0x00000000c64f8f40> (a java.io.InputStreamReader)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:321)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:300)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:523)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:847)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:785)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3409)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3339)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:3016)
at com.motionFashion.DropShippingApplication.JobScheduler.Schedular.copyFileFromFTPtoAWS(Schedular.java:108)
at com.motionFashion.DropShippingApplication.JobScheduler.Schedular.performDailyTask(Schedular.java:61)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.9/Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.9/NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.9/DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(java.base@11.0.9/Method.java:566)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(java.base@11.0.9/Executors.java:515)
at java.util.concurrent.FutureTask.runAndReset(java.base@11.0.9/FutureTask.java:305)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(java.base@11.0.9/ScheduledThreadPoolExecutor.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.9/ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.9/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.9/Thread.java:834)
"scheduling-1" #45 prio=5 os_prio=0 cpu=160.16ms elapsed=435.39s tid=0x00005618fef93800 nid=0x4a6f runnable [0x00007f34322fc000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(java.base@11.0.9/Native Method)
at java.net.SocketInputStream.socketRead(java.base@11.0.9/SocketInputStream.java:115)
at java.net.SocketInputStream.read(java.base@11.0.9/SocketInputStream.java:168)
at java.net.SocketInputStream.read(java.base@11.0.9/SocketInputStream.java:140)
at sun.nio.cs.StreamDecoder.readBytes(java.base@11.0.9/StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(java.base@11.0.9/StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(java.base@11.0.9/StreamDecoder.java:178)
- locked <0x00000000c6681ff8> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(java.base@11.0.9/InputStreamReader.java:185)
at java.io.BufferedReader.fill(java.base@11.0.9/BufferedReader.java:161)
at java.io.BufferedReader.read(java.base@11.0.9/BufferedReader.java:182)
- locked <0x00000000c6681ff8> (a java.io.InputStreamReader)
at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58)
- locked <0x00000000c6681ff8> (a java.io.InputStreamReader)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:321)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:300)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:523)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:847)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:785)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3409)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3339)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:3016)
at com.motionFashion.DropShippingApplication.JobScheduler.Schedular.copyFileFromFTPtoAWS_v2(Schedular.java:95)
at com.motionFashion.DropShippingApplication.JobScheduler.Schedular.performDailyTask(Schedular.java:61)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.9/Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.9/NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.9/DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(java.base@11.0.9/Method.java:566)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(java.base@11.0.9/Executors.java:515)
at java.util.concurrent.FutureTask.runAndReset(java.base@11.0.9/FutureTask.java:305)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(java.base@11.0.9/ScheduledThreadPoolExecutor.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.9/ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.9/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.9/Thread.java:834)
用于调度的函数
public void copyFileFromFTPtoAWS_v2(User user ){
System.out.println("****************--------copyFileFromFTPtoAWS--------****************");
System.out.println("user -:"+user.getUsername());
int port = 21;
String ftp_server =user.getFtp_server();
String ftp_username = user.getFtp_username();
String ftp_password = user.getFtp_password();
FTPClient ftpClient = new FTPClient();
FTPClientConfig conf = new FTPClientConfig();
conf.setServerTimeZoneId("UTC");
ftpClient.configure(conf);
try {
ftpClient.connect(ftp_server, port);
ftpClient.login(ftp_username, ftp_password);
System.out.println("listFiles--->message");
FTPFile[] message = ftpClient.listFiles("/message");
System.out.println("list-message"+message.length);
System.out.println("listFiles--->order");
FTPFile[] order = ftpClient.listFiles("/order");
System.out.println("list-order"+order.length);
String path = ftpClient.printWorkingDirectory();
System.out.println("path :"+path);
}
catch (Exception e)
{
System.out.println(e);
}
}
在schedular中,我检查了活动用户,然后将用户发送到上面的函数,以获取ftp服务器中的两个文件夹“message”和“order”的文件。但在ftpfile[]message=ftpclient.listfiles(“/message”)中;我得到了错误。
在jobschedular上执行每日任务函数
@Autowired
Ftp_File_service ftpFile_service;
@Autowired
storageService storageService;
@Autowired
UserService userService;
@Autowired
OrderService OrderService;
@Autowired
EmailService emailService;
DateFormat dateFormater2 = new SimpleDateFormat("dd_MM_yyyy_HH_mm");
DateFormat dateFormater = new SimpleDateFormat("dd-MM-yyyy_HH:mm");
FTPClient ftp = null;
private static final int BUFFER_SIZE = 4096;
//300000 -> 5 min
//600000 -> 10 min
@SuppressWarnings({ "resource", "unused" })
@Scheduled(fixedRate = 600000)//..................................................................UPDATE bestand_komplett
public void performDailyTask(){
System.out.println("**************************performDailyTask**************************");
List<User> userList = userService.findAllClient();
if(!userList.isEmpty())
{
List<User> newUserList=userService.findAllActiveClient(userList);
if(!newUserList.isEmpty()){
for(User user : newUserList)
{
copyFileFromFTPtoAWS_v2(user);
}
}
}
}
新错误
**************************performDailyTask**************************
time
26/04/2021 20:48:41
****************--------copyFileFromFTPtoAWS--------****************
user -:mds001
listFiles--->message
list-message0
listFiles--->order
26-Apr-2021 20:51:58.272 INFO [http-nio-8080-exec-2] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the HTTP protocol [HTTP/1.10x0aHost:]
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:559)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
1条答案
按热度按时间tp5buhyn1#
这两行ftp连接后解决了我的问题。因为我没有得到任何错误,除了一些警告日志文件。