-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Can't find the location of file keystore when running as jar #9089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This works fine in our Tomcat SSL sample. Please try with the latest 1.4.x release (1.4.6.RELEASE) and, if that doesn't help, please provide a small sample that reproduces the problem. |
it works fine in IntelliJ IDEA. If I build it as a jar and run this jar, it will show this Exception |
I already understood that from your original description when you said it can't read the keystore from a jar file. As I said above, it works fine in our sample so we're going to need to see a sample from you that reproduces the problem. |
Thanks. I fixed it by your samples. |
@wilkinsona Properties:
Exception:
|
@GursharanKhalsa Please see my comments above. If you’d like someone to spend some time trying to help you, please provide a small sample that reproduces the problem. Before doing that, I’d check that you have a file named |
@wilkinsona Thanks for the reply but this problem occur because of classpath resource when I run in eclipse it would easily find the .jks file but after building the project into single.jar. The .jks file would not find as a classpath resource so I resolved it by replacing But I would like to know about if we add some required resources in |
@GursharanKhalsa Loading a keystore from a jar file should work. As I’ve already said above, if you’d like someone to spend some time trying to help you, please provide a small sample that reproduces the problem. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I am also facing the same issue |
I think it is a bit more general problem, try to load a resource from a spring boot jar as an URL instead of a File. Like this way: |
i had the same problem and i just solved it like that: no "/" for the "src" |
Thanks for trying to help out, @Brice-D. Please be aware that pointing to |
My application files has :
and I can't even change the code for ks = KeyStore.getInstance(KeyStore.getDefaultType());
URL resource = this.getClass().getClassLoader().getResource(config.getTruststore());
if(resource == null) {
System.out.println("Could not find the truststore located at [" + config.getTruststore()+ "]");
} else {
File file = new File(resource.toURI());
FileInputStream fis = new FileInputStream(file);
ks.load(fis, config.getTruststorePassword().toCharArray());
} In my local it works fine, but deploying it to any external server (k8) I get this as URI is not hierarchical .. and if i copy it o some location and provide the path .. I get exception "System.out.println("Could not find the truststore located at [" + config.getTruststore()+ "]");"... Any suggestions .. |
I use Spring Boot 1.4.0. And I find that tomcat can't read the keystore conatined in a jar. But how can I load the keystore in a jar.
The configuration about SSL:
The Exception:
java.io.FileNotFoundException: class path resource [xx.jks] cannot be resolved to absolute file path because it does not reside in the file system:jar:file:/C:/xx/xx/xx/xx/xx/target/xx-1.0-SNAPSHOT.jar!/xx.jks
The text was updated successfully, but these errors were encountered: