Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

java - Camel FTPs FileNotFoundException with keystore file in resources of war

I've trying to connect my Spring Boot application to FTPs server via camel-ftp. And I configured keystore file by ftpClient.trustStore.file parameter in FTPs Connection Uri. It's work as normal with running debug in IDE but when packaging application to war file and deploy in Docker container. I got FileNotFoundException : Caused by: java.io.FileNotFoundException: file:/usr/app/app.war!/WEB-INF/classes!/keys/diode.jks (No such file or directory)

I've tried to check

  1. Extra war file and keystore already existed in /classes/keys folder (it be coppied from /resources/keys folder in source code)
  2. Add log and I can get content of keystore file when running application with war but can not get file path to pass to FTPs connection Uri.

How can I get real file keystore file path in war and pass to ftpClient.trustStore.file parameter in FTPs connection Uri with camel-ftp

question from:https://stackoverflow.com/questions/65841427/camel-ftps-filenotfoundexception-with-keystore-file-in-resources-of-war

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From the exception message, I would infer that something is trying to open a "file:" URL as if it was a regular file pathname. That won't work.

  1. If you have something that needs a file path you need to give it a real file path. Not a file: URL.

  2. If a URL refers to a resource inside a JAR or WAR file, there is no valid filesystem path for it. Stuff inside an archive file cannot be opened that way. Your operating system's "open file" syscalls require a pathname not a URL.

So what you are probably going to have to do is to extract the keystore file from the WAR and write it to a file in the file system. (It sounds like this has already been done.) Then you need to change the FTPS connection URL to use the pathname of that file file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...