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
Related
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
In my Spring Boot configuration file, can I specify a logging file location relative to the Spring Boot jar instead of relative to the directory the jar is started from?
Example:
#application.yml
logging:
file: ./logs/app.log
Directories:
/app/dir/app.jar
/random/dir
Start:
cd /random/dir
java -jar /app/dir/app.jar
Result:
/random/dir/logs/app.log
Desired:
/app/dir/logs/app.log
Additional Info:
The jar will be running on different operating systems. So the jar path could be similar to:
/app/dir/app.jar
C:\app\dir\app.jar
At run time, I can calculate what the jar/install directory is. Is there a Java solution that would allow me to set the logging.file location after startup? Or is the logger already initialized at that point?
Complete Solution: based on #satyesht
#application.yml
app:
log:
#Set a default directory in case a user "double clicks" the jar to launch it.
dir: ./logs
file: app.log
logging:
file: ${app.log.dir}/${app.log.file}
Start:
cd /random/dir
java -Dapp.log.dir=/app/dir/logs -jar /app/dir/app.jar
One simple way would be to pass the log directory as a system property as below .
#application.yml
logging:
file: ${LOGDIR}/logs/app.log
and while running your application you can specify the LOGDIR system property as a VM argument
cd /random/dir
java -jar /app/dir/app.jar -DLOGDIR=/app/dir/
You would have to know the location of the jarfile ahead of time. But yes, the difference is between absolute, and relative paths.
Using . indicates that you want to start from the location where our console window is open. This is a path that is relative to the location you are in the terminal.
Using / indicates that you want to start at the root of the drive. Now, obviousally you don't want to store the file in the root of the drive. But let's say i Had my jar in the folder: /app/dir/app.jar Then configuration is as simple as saying:
#application.yml
logging:
file: /app/dir/logs/app.log
I installed a HDP 2.5 Hadoop/Spark cluster using cloudbreak on Azure.
Everything works except the spark history server. In the log it says the default uri for the event log hdfs:///spark-history is false, the hostname is missing.
So I replaced it with a direct reference to the actual location on the azure blob storage: wasb://<host>:<port>/spark-history. This uri works when used with hdsf dfs -ls, but still the spark history server won't start. Now it complains about a class not found: Caused by: java.lang.NoClassDefFoundError: com/microsoft/azure/storage/blob/BlobListingDetails.
So, it seems it doesn't load some driver during start. I did find /usr/hdp/current/hadoop-client/lib/azure-storage-2.2.0.jar, that might be it. But I'm not sure how to make the history server load the jar during startup using the ambari config editor or whether this is even the right solution to the original problem.
The strangest thing is that Azure HDInsight uses blob storage and there the spark history server simply runs using the default hdfs:///spark-history setting.
Any suggestions on how to load the azure-storage driver or any other approach to this problem?
Thanx
I'll answer my own question. Someone on the hortonworks community forum had the answer: the spark assembly jar contains invalid storage jars. Updating the assembly jar solves the issue:
mkdir -p /tmp/jarupdate && cd /tmp/jarupdate
find /usr/hdp/ -name "azure-storage*.jar"
cp /usr/hdp/2.5.0.1-210/hadoop/lib/azure-storage-2.2.0.jar .
cp /usr/hdp/current/spark-historyserver/lib/spark-assembly-1.6.3.2.5.0.1-210-hadoop2.7.3.2.5.0.1-210.jar .
unzip azure-storage-2.2.0.jar
jar uf spark-assembly-1.6.3.2.5.0.1-210-hadoop2.7.3.2.5.0.1-210.jar com/
mv -f spark-assembly-1.6.3.2.5.0.1-210-hadoop2.7.3.2.5.0.1-210.jar /usr/hdp/current/spark-historyserver/lib/spark-assembly-1.6.3.2.5.0.1-210-hadoop2.7.3.2.5.0.1-210.jar
cd .. && rm -rf /tmp/jarupdate
I have a problem with HSQLDB V2.3 on Windows. I can't connect with new databases using the HSQLDB Server.
Is there a log or debug option for the server so I can check the properties loaded and file paths, etc?
Is my properties file OK? I wasn't sure how to formulate file paths for windows.
Can I use quotes on file path names?
Is the connection string I'm using for the tmp db correct?
What's the correct syntax to use the --props server argument?
--props path
--props path/filename
I have set-up two environment variables (too keep it simple*). These variables don't have any effect except to save my typing. Initially I was loading the server from the HSQLDB folder directly.
HSQLDB_HOME ... home folder for the current HSQLDB
HSQLDB_DATA ... folder for data repository
I am following the the steps from:
Running and Using HSQLDB
Every time I connect via the server it makes a database called, "test" instead of letting me connect to either of the two databases specified in the server.properties.
%HSQLDB_DATA%/
test.log
test.properties
test.script
test.tmp/ .......... (folder)
test.lck
I made a 'server.properties' file in:
%HSQLDB_HOME%/lib/
where the HSQLDB JAR file is. I want two databases: tmp and dev:
# -- tmp
server.database.0=file:hsqldb/tmp_db/tmp
server.dbname.0=tmp_db
#
####
#
# -- dev
server.database.1=file:r:/.data/hsqldb/dev_db/dev
server.dbname.1=dev_db
I expected that the properties file to be enough to set-up two databases. When I run the hsqldb manager I don't get a connection for tmp say:
"jdbc:hsqldb:hsql://localhost/tmp"
user: SA, password: ""
I get a pop-up error:
database alias does not exist (Manager)
[Thread[HSQLDB Connection #26827674,5,HSQLDB Connections #372f7a8d]]: database alias=tmp does not exist (Server)
I created these two manually using the cmd-line, e.g. named "tmp":
%JAVA_HOME%\bin\java.exe -classpath %HSQLDB_HOME%\lib\hsqldb.jar org.hsqldb.server.Server org.hsqldb.server.Server --database.1 file:r:/.data/hsqldb/tmp_db --dbname.1 tmp_db
And could connect and create tmp:
%HSQLDB_DATA%/tmp_db/
tmp.log
tmp.properties
tmp.script
tmp.tmp/ .......... (folder)
tmp.lck
as forecast in the documentation. When I start-up the HSQLDB Server with the aforesaid 'server.properties' file or specifying properties explicitly:
%JAVA_HOME%\bin\java.exe -classpath %HSQLDB_HOME%\lib\hsqldb.jar org.hsqldb.server.Server --trace true --props %HSQLDB_DATA%
The server will only let me connect with a database called "test" as described at the beginning of the question.
Because the properties file looks good and the in-process file connection string works,
jdbc:hsqldb:hsqldb/tmp_db/tmp
I am left considering that the server.properties file is in the wrong place or not loading for some reason. It would be wonderful if there's a way for the server to dump the properties file at start-time :-) Thanks in advance for your suggestions ...
I have found the problem. Firstly, thanks to this tutorial:
HSQLDB Installation
After reviewing this I realised my error.
The server.properties file must be in the current folder when the server script runs. I had read that on the Running and Using HSQLDB manual page but misinterpreted its meaning and I put the properties file in my %HSQLDB_HOME%/lib folder. Oops.
When you look at the BAT script, it actually changed the current folder to be the %HSQLDB_HOME%/data folder ...
cd ..\data
So the default location for your server.properties file should be your: %HSQLDB_HOME%/data if you want to work with the default runServer.bat script.
For those wanting to separate data from the server software. I made an improvement for the default script using the two environment variables as follows.
HSQLDB_HOME ... home folder for the current HSQLDB
HSQLDB_DATA ... folder for data repository
runServer.bat:
#cd /d %HSQLDB_DATA%
#cd
#echo.
#rem __ #pause
%JAVA_HOME%\bin\java -classpath %HSQLDB_HOME%\lib\hsqldb.jar org.hsqldb.server.Server %1 %2 %3 %4 %5 %6 %7 %8 %9
#echo.
#pause
Which now expects my server.properties file in the %HSQL_DATA% folder. And that works. Also for my server since it is for development /testing, I'm using the --trace=true option. Like a lot of these things, now I get-it, it all makes perfect sense. Hopefully my misunderstanding will assist others who haven't found a simple tutorial before resorting to stackoverflow.
In my project, I have a special JSP which displays the exception stacktrace in case of Exceptions.
Is there a way to use an URL handler or something else which would have Eclipse open a file? Maybe with xdg-open?
I use Eclipse 4.3 on Kubuntu Linux.
I've ended up with this solution:
Edit xdebug.ini (it should be somewhere like /etc/php/7.0/mods-available/xdebug.ini), add:
xdebug.file_link_format="xdebug://%f(%l)"
Restart your server or php-fpm. For Apache on Ubuntu use sudo service apache2 restart.
Create eclipse-launch.sh. It is intended to parse URL and pass a file to Eclipse. You can name it as you want and put it anywhere you want, I've placed it in the eclise directory. Be sure to replace /home/user with your actual home directory and path="..." with actual eclipse path:
#! /bin/bash
arg=$1
path="/home/user/eclipse/eclipse-neon/"
# file name directly followed by a line number in parenthesis
regex="//([^(]*)\(([0-9]+)\)"
if [[ $arg =~ $regex ]]
then
file=${BASH_REMATCH[1]}
line=${BASH_REMATCH[2]}
$path/eclipse --launcher.openFile "$file"+"$line"
else
msg="Unsupported URL: $arg"
zenity --info --text="$msg"
# alternatives:
# notify-send "$msg" # another notification program
# $path/eclipse # just run eclipse
fi
Read more about Eclipse command line options here: http://help.eclipse.org/mars/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/product_open_file.htm
Give the file executable permissions: chmod +a eclipse-launch.sh
Create xdebug.desktop at ~/.local/share/applications/. It will be used by xdg-open (Chrome uses xdg-open by default).
[Desktop Entry]
Comment=
Exec=/home/user/eclipse/eclipse-neon/eclipse-launch.sh "%u"
Icon=/home/user/eclipse/eclipse-neon/eclipse/icon.xpm
Name=Eclipse xdebug Launch
NoDisplay=false
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
MimeType=x-scheme-handler/xdebug;
Run xdg-mime default xdebug.desktop x-scheme-handler/xdebug. This should add an entry to ~.local/share/applications/mimeapps.list to [Default Applications] section. The entry itself should look like x-scheme-handler/xdebug=xdebug.desktop
For Firefox follow instructions from here: https://xdebug.org/docs/all_settings#file_link_format
Open about:config
Add a new boolean setting network.protocol-handler.expose.xdebug and set it to false
The first time you click on xdebug:/// link Firefox will prompt you to select an application to run, point to the created eclipse-launch.sh file.