I was getting this error when running
systemctl restart tomcat in my
$CATALINA_HOME/logs/catalina.out log file:
So I followed this post online: https://confluence.atlassian.com/confkb/permission-denied-error-when-binding-a-port-290750651.html
- If using Linux 2.6.24 or later, you can set up a file capability on the java executable, to give elevated privileges to allow opening privileged ports only, and no other superuser privileges:
setcap cap_net_bind_service+ep /path/to/bin/java After setting this you may notice errors when starting Java like this, for example:
$ java -version /path/to/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory This means that the library is being imported from a dynamic path, and not in the trusted ld.so path. See https://bugs.java.com/bugdatabase/view_bug?bug_id=7157699 for details. To fix this, you need to locate the library, and add its path to the ld.so configuration. Note that the below is an example, and this may differ depending on Linux distribution. Replace JAVA_HOME with the correct location:
$ find JAVA_HOME -name 'libjli.so' JAVA_HOME/lib/amd64/jli/libjli.so
echo "JAVA_HOME/lib/amd64/jli" > /etc/ld.so.conf.d/java-libjli.conf ldconfig -v After setting this all up, you need to make sure that Confluence only starts java with the direct binary path, and not via a symbolic link, otherwise the capability will not be picked up.
So I ran this command: setcap cap_net_bind_service+ep /usr/lib/jvm/java-1.8.0-openjdk-184.108.40.206-0.b14.el7_4.x86_64
And I'm getting what it says I might get:
$CATALINA_HOME/logs/catalina.out /usr/lib/jvm/java-1.8.0-openjdk-220.127.116.11-0.b14.el7_4.x86_64/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
I did what they said to fix it but it's still not working and I'm still getting the above error:
$ find $JAVA_HOME -name 'libjli.so' /usr/lib/jvm/java-1.8.0-openjdk-18.104.22.168-0.b14.el7_4.x86_64/jre/lib/amd64/jli/libjli.so /usr/lib/jvm/java-1.8.0-openjdk-22.214.171.124-0.b14.el7_4.x86_64/lib/amd64/jli/libjli.so
I have two of these for some reason. I created this file with the paths, but I'm still getting the error and my tomcat isnt starting.
$ cat /etc/ld.so.conf.d/java-libjli.conf /usr/lib/jvm/java-1.8.0-openjdk-126.96.36.199-0.b14.el7_4.x86_64/jre/lib/amd64/jli /usr/lib/jvm/java-1.8.0-openjdk-188.8.131.52-0.b14.el7_4.x86_64/lib/amd64/jli