By martinzokov
I am trying to set up a simple Spring application to use SSL and host it on Digital Ocean. Why is my app not finding the keystore file?
The droplet I’ve set up is based on Ubuntu 18.04. I used Letsencrypt to get a certificate and this guide to generate a PKCS file. I’ve set up my application.properties file to look in the jar file’s current directory like so:
security.require-ssl:true server.ssl.key-store:keystore.p12 server.ssl.key-store-password:<password> server.ssl.key-store-type:PKCS12 server.ssl.key-alias:<alias> I would expect this to run and start a web server on the configured port. However, what I get in the stack trace is this:
Caused by: java.io.FileNotFoundException: /root/software/gimmememe/target/keystore.p12 (No such file or directory) Weirdly enough when I run the same jar with the same keystore.p12 file on my own Windows machine it runs fine:
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9123 (https) with context path ‘’ meme.Application : Started Application in 4.985 seconds (JVM running for 5.464) I don’t think it’s a permissions issue on the Ubuntu machine as I tried setting the permissions on the keystore file like so:
-rw-r–r-- 1 root root 4274 Mar 26 18:44 keystore.p12 I am running my jar file with the following command (tried with sudo infront as well):
java -jar gimme-meme-1.0.0.war
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Greetings!
This problem sounds like it could lean either direction as far as simple/complex. Given that the error is “No such file or directory” I’d like to make no assumptions and jump to the simplest test. Upon seeing that error, even if I knew the file was there, I’d be running this command immediately:
stat /root/software/gimmememe/target/keystore.p12
The reason being that I want to rule out any issues that my eyes might be skipping over. You and I might look at it a hundred times and never see it, so let’s zone in on that possibility. When you run that, what happens? I expect one of two outcomes:
stat: cannot stat ‘/root/software/gimmememe/target/keystore.p12’: No such file or directory
A result, something similar to:
[root@banshee] ~ # stat test
File: ‘test’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 902h/2306d Inode: 63970934 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-03-26 19:41:52.163693050 +0000
Modify: 2019-03-26 19:41:52.163693050 +0000
Change: 2019-03-26 19:41:52.163693050 +0000
Birth: -
If you get the result from #1, the file surely isn’t in that location. So ask yourself what is different from where you’re running it, as opposed to that location, and why it might be searching there. I don’t know those answers for your situation, but they may be the right questions.
If you get the result from #2, then I’m going to ask you what the result of this command is:
lsattr /root/software/gimmememe/target/keystore.p12
Perhaps the file has a strange flag on it that can throw off the java app. I doubt it, but I’m up for the idea. That test file I just made for the stat example above, it has no strange flags and here’s what it looks like:
[root@banshee] ~ # lsattr test
-------------e-- test
If you get this far and you can say all of these are true:
Then I propose that the disconnect is between the application and the installed java version, but I don’t know what exactly that would be. Hopefully someone else has an idea. I can’t see it being that, the error is a pretty clear OS error.
Jarland
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.