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
Spring loads the file from the classpath, which allows, so you should prefix the path with that classpath:, e.g.
server.ssl.key-store : classpath:keystore.p12
Or if you use the = symbol as a key/value delimiter:
server.ssl.key-store = classpath:keystore.p12
Bear in mind that the value is only trimmed on the left side, so you can not have any trailing whitespace after the value.
I had exactly the same issues and could resolve it.
I stored the keystore file in src/main/resources/keystore.p12, but in the jar file it was under classes/ directly.
My solution was:
server.ssl.key-store=classpath:keystore.p12
It looks like your app is just looking in the current directory for the keystore.p12 file, as indicated by:
Caused by: java.io.FileNotFoundException: /root/software/gimmememe/target/keystore.p12 (No such file or directory)
Most likely, you need to tell Spring Boot that the file is in the jar.
For example, if you keep the file at src/main/resources, gradle & maven will place that file at the root of the classpath. To convey this information to the spring boot app, you'll want to tell it the file is on the classpath.
That means you need to set server.ssl.key-store to classpath:keystore.p12, so that Spring knows it needs to load the keystore from within the archive's classpath.
-- EDIT --
Here's an example of someone having a similar problem that illustrates this fix.
Github Issue of Similar Problem
Related
Getting the below response while running jmeter.server Batch file:
Could not find ApacheJmeter_core.jar ...
what to do now? I am using Java version-14
Could not find ApacheJmeter_core.jar ... meaning you haven't started Jmeter master.
But above error is different, in this case Jmeter slave cannot find rmi keystore file at bin folder thus throwing file not found exception for rmi_keystore.jks.
You have to generate rmi_keystore.jks by running create-rmi-keystore.bat for windows (for mac you have to run create-rmi-keystore.sh) then once .jks file is generated then copy it in bin folder of each Jmeter slave.
For more details, you can refer link: https://jmeter.apache.org/usermanual/remote-test.html#setup_ssl
I had installed Websphere Liberty Runtime in a Windows 7 machine following the instructions here :
https://developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse-environments/
I had installed and configured the admin-center feature following these instructions :
http://www-01.ibm.com/support/knowledgecenter/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/twlp_ui_setup.html
I set two users : admin and nonadmin
I am able to connect to this server from Eclipse in another computer.
However, each time i try to deploy an application on this server, i get this error in the computer with Eclipse :
Publish HelloWorldApplication
OK
Failed to transfer application HelloWorldApplication
CWWKX0121E: Access denied to path C:/wlp/usr/servers/servername/apps/HelloWorldApplication.war.
Failed to synchronize server configuration.
CWWKX0121E: Access denied to path C:/wlp/usr/servers/servername/server.xml.
Deployment of application HelloWorldApplication failed.
And, in the server i got this :
[ERROR ] CWWKX7901E: The C:/wlp/usr/servers/servername/apps/HelloWorldApplication.war file system path is not valid.
Can anyone help me, please ?
We are more than one developer needing to work on this server.
Thanks in advance.
SJRM
How do you have your server.xml configured? Given the error you mention, I think it's missing the configuration for writing into the remote directories, which looks something like this:
<remoteFileAccess>
<writeDir>${writePath}</writeDir>
</remoteFileAccess>
You can define several write directories and each one can refer to variables or absolute paths, for example:
<remoteFileAccess>
<writeDir>${wlp.user.dir}</writeDir>
</remoteFileAccess>
You can obtain the basic configuration for remote administration by executing this command on you Liberty profile bin directory:
configUtility install remoteAdministration
For reference see:
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/t_creating_remote_server.html?cp=SSEQTP_8.5.5%2F1-3-11-0-2-3 for setting up a remote server,
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/rwlp_command_configutil.html%23rwlp_command_configutil?cp=SSEQTP_8.5.5%2F1-3-11-0-3-2-1-1&lang=en for reading about the configUtility and
http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/rwlp_dirs.html?cp=SSEQTP_8.5.5%2F1-3-11-0-2-0&lang=en for a list of Liberty profile properties and their corresponding directories.
I'm trying to run Jetty on CentOS and am having problems as I am getting unexpected results when I try to set the full path for JETTY_LOGS. The system tries to take that path and append it to the path I specified in the JETTY_HOME variable.
JETTY_HOME=/usr/local/jetty/jetty-9.1.4
JETTY_USER=jetty
JETTY_PORT=8085
JETTY_HOST=0.0.0.0
JETTY_LOGS=/usr/local/jetty/jetty-9.1.4/logs
Any ideas as to what I'm doing wrong?
The error I get is:
Starting Jetty: java.io.IOException: Cannot write start.log to directory
/usr/local/jetty/jetty-9.1.4/usr/local/jetty/jetty-9.1.4/logs [directory doesn't exist or is read-only]
java.io.IOException: Cannot write start.log to directory /usr/local/jetty/jetty-9.1.4/usr/local/jetty/jetty-9.1.4/logs [directory doesn't exist or is read-only]
at org.eclipse.jetty.start.StartLog.initLogFile(StartLog.java:127)
at org.eclipse.jetty.start.StartLog.initialize(StartLog.java:113)
at org.eclipse.jetty.start.Main.processCommandLine(Main.java:520)
at org.eclipse.jetty.start.Main.main(Main.java:102)
It seems that JETTY_LOG directory is relative to JETTY_HOME.
Could you try to set:
JETTY_LOGS=/logs
or alternatively
JETTY_HOME=/usr/local/jetty/jetty-9.1.4/
JETTY_LOGS=logs
You're not doing anything wrong, this is new behavior in jetty 9.1.4:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=432192
Workaround is to set the JETTY_LOGS env var relative to your jetty base dir (like the logs dir that comes in the standard jetty tarball):
JETTY_LOGS=logs
Which will resolve to /usr/local/jetty/jetty-9.1.4/logs in your case (the jetty base dir defaults to the jetty home dir).
If you want the logs written somewhere outside of your jetty base dir, the best way is to use the above JETTY_LOGS=logs env setting, and just symlink the dir elsewhere; like this to create and link to the common /var/log/jetty dir:
# mv /usr/local/jetty/jetty-9.1.4/logs /var/log/jetty
# ln -s /var/log/jetty /usr/local/jetty/jetty-9.1.4/logs
Whatever you do, also make sure that the user as which you run jetty has write access to the logs dir; if you use the jetty user in the jetty group, make it the owner of your logs dir:
# chown -R jetty:jetty /var/log/jetty
I am following
Red5 Media Server - Workspace Setup Guide - r4737!
I am able to build Red5 distribution and rename distribution jar files i.e completed upto step 6.But when I followed step 7 - Run inside of eclipse failed to debug it as java application -
Red5 root: /home/yuvraj/Documents/RED5/red5 java code all/java/server/trunk
Configuation root: /home/yuvraj/Documents/RED5/red5 java code all/java/server/trunk/conf
Red5 server jar was not found, using fallback.
URL list: [file:/home/yuvraj/Documents/RED5/red5%20java%20code%20all/java/server/trunk/red5.jar]
Bootstrap exception: null
Bootstrap exit
java.lang.NullPointerException
at org.red5.classloading.ClassLoaderBuilder.build(ClassLoaderBuilder.java:172)
at org.red5.classloading.ClassLoaderBuilder.build(ClassLoaderBuilder.java:96)
at org.red5.server.Bootstrap.bootStrap(Bootstrap.java:117)
at org.red5.server.Bootstrap.main(Bootstrap.java:48)
I couldn't find conf directory neither in /home/yuvraj/Documents/RED5/red5 java code all/java/server/trunk/ nor in /Red5_server/bin while setting classpath in java debug.
If you followed step by step the guide, you are probably using the 1.0.2 RC4.
Try this now:
Extract the red5-server-1.0.2-RC4.zip from the target folder to a custom folder
(I have it in c:\red5-server-1.0.2-RC4 )
Copy red5.jar and bootstrap.jar in the place you extracted red5. (In my case c:\red5-server-1.0.2-RC4\ )
Repeat the step 7 in the Guide and be carefull at point L.
conf directory is in \red5-server-1.0.2-RC4\
From the output you've shown, I'd assume you're missing the lib directory and its contents. This wiki link should help: https://code.google.com/p/red5/wiki/ServerWontStart#Bootstrap_exception
I've got a problem with JacORB 3.2 as it seems that it doesn't read the orb.properties file, and especially the ORBInitRef.NameService property.
As stated in the documentation on chapter 3.1, JacORB automatically searches for the orb.properties file in three locations: the "java.home"/lib directory, the "user.home" directory and inside the classpath.
This is the evidence that I'm not totally drunk:
Java command:
System.out.println(System.getProperty("java.home"));
System.out.println(System.getProperty("user.home"));
Output:
/usr/lib/jvm/jdk1.7.0/jre
/home/emanuele
Bash command:
ls /usr/lib/jvm/jdk1.7.0/jre/lib | grep orb.properties ; ls /home/emanuele | grep orb.properties
Output:
jacorb.properties
orb.properties
jacorb.properties
orb.properties
These four .properties file are exactly the same. Please have a look at the URI of the file that contains the reference (IOR) of the NameService:
ORBInitRef.NameService=file:/tmp/CORBA/NS_Ref
The problem is that, when I try to launch the NameService without any parameter (ns) I got these error messages:
giu 05, 2013 9:56:51 PM org.jacorb.naming.NameServer main
SEVERE: unexpected exception
java.io.FileNotFoundException: c:/NS_Ref (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
at org.jacorb.naming.NameServer.main(NameServer.java:320)
java.lang.RuntimeException: c:/NS_Ref (No such file or directory)
at org.jacorb.naming.NameServer.main(NameServer.java:335)
Of course, if I explicitely pass the URI through console, everything goes fine
ns -Djacorb.naming.ior_filename=/tmp/CORBA/NS_Ref
The very strange thing is that, after the NameService is running, EVERY OTHER OBJECT can correctly and automatically resolve the initial reference of the NameService.
NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
The previous Java code returns a valid object. That does not make any sense for me.
And why does the NameService try to write its IOR inside a random file like C:\NS_Ref while I'm on Linux?
Any idea?
I thing you mixed up some different things in your question.
The location of the NS's IOR
The ability to read and use this IOR by other programs
First. Starting the NamingService is not affected by option ORBInitRef.NameService or any related commandline option. If you want the NamingService to drop it's IOR in a file, use
# The file where the name server drops its IOR
jacorb.naming.ior_filename=file:///tmp/CORBA/NS_Ref
as you already did. If this behaves different when using this as cmdline option, see 2.
Second. JacORB its config files are not OS specific - there is a mix of both Linux and Windows style. Don't rely on that.
Your call to ns will call the jaco script in JacORBs bin directory. Activate the verbosity stuff at the end of the file, then start ns again and see which jre and jacorb.home are really used. Look for configs. Remove ALL other configs you do not need.
Retry.
This
ns -Djacorb.naming.ior_filename=/tmp/CORBA/NS_Ref
looks fine, but shouldn't that
ORBInitRef.NameService=file:/tmp/CORBA/NS_Ref
read file:///tmp/CORBA/NS_Ref?
And this
c:/NS_Ref
is strange on Linux; that looks very windowzy to me; are you sure you've not mixed Win and Linux config files?