[CONTROLLER-1525] Can't start karaf using symbolic link Created: 07/Jun/16  Updated: 03/May/18  Resolved: 01/Aug/16

Status: Resolved
Project: controller
Component/s: karaf
Affects Version/s: Lithium
Fix Version/s: None

Type: Bug
Reporter: Alexis de Talhouët Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 6027

 Description   

When using symbolic link, e.g.

root@foo:/usr/bin# ls -ls karaf
1 lrwxrwxrwx 1 root root 27 Jun 2 15:42 karaf -> /opt/opendaylight/bin/karaf

karaf fail to start because of wrong DIRNAME, as DIRNAME is based on $0 being the path of the executed file.
So in this case, DIRENAME=usr/bin, which doesn't work.

Karaf script is setting multiple env variable to be able to start correctly, and all of those variables are based on the KARAF_HOME, that is tied to the DIRNAME.



 Comments   
Comment by Alexis de Talhouët [ 08/Jun/16 ]

For Ubuntu (Linux vagrant 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux)
this is the symbolic link
```vagrant@vagrant:~$ ls -l /usr/bin/karaf
lrwxrwxrwx 1 root root 60 Jun 8 13:08 /usr/bin/karaf -> /home/vagrant/distribution-karaf-0.3.4-Lithium-SR4/bin/karaf
```
When I use it, here is the result:
```vagrant@vagrant:~$ karaf
/usr/bin <— echo $DIRNAME
Error: Could not find or load main class org.apache.karaf.main.Main
```
When I use the target of the symbolic link
```vagrant@vagrant:~$ /home/vagrant/distribution-karaf-0.3.4-Lithium-SR4/bin/karaf
/home/vagrant/distribution-karaf-0.3.4-Lithium-SR4/bin <— echo $DIRNAME

For OSX (Darwin inocybe.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64)
this is the symbolic link
```adetalhouet@inocybe:~\> ls -l /usr/bin/karaf
lrwxr-xr-x 1 root wheel 61B 8 Jun 09:01 /usr/bin/karaf@ -> /Users/adetalhouet/odl/unimgr/karaf/target/assembly/bin/karaf
```
When I use it, here is the result:
```adetalhouet@inocybe:~\> karaf
/usr/bin <— echo $DIRNAME
Error: Could not find or load main class org.apache.karaf.main.Main
```
When I use the target of the symbolic link
```adetalhouet@inocybe:~\> /Users/adetalhouet/odl/unimgr/karaf/target/assembly/bin/karaf
/Users/adetalhouet/odl/unimgr/karaf/target/assembly/bin <— echo $DIRNAME

Comment by Alexis de Talhouët [ 08/Jun/16 ]

JIRA opened in Karaf project https://issues.apache.org/jira/browse/KARAF-4564

Comment by Michael Vorburger [ 30/Jun/16 ]

https://issues.apache.org/jira/browse/KARAF-4599

Comment by Michael Vorburger [ 22/Jul/16 ]

I've just amended https://git.opendaylight.org/gerrit/#/c/39982/ with the solution proposed on https://issues.apache.org/jira/browse/KARAF-4599 (upstream is slow to react, so let's just apply this here, we've anyway forked the Karaf scripts already, so we can continue to patch them).

FTR: Alexis pointed out (on IRC) that his initial solution https://git.opendaylight.org/gerrit/#/c/39982/2/karaf/opendaylight-karaf-resources/src/main/resources/bin/karaf worked fine with both absolute and relative path. But Karaf dev jbonofre then pointed out on https://github.com/apache/karaf/pull/196 that realpath as it's not available on most of Unix systems, so it was changed to readlink. That initially caused it to "now only works when invoked from current directoy, no longer via absolute path" (KARAF-4599).

So with the latest patch set 10 in c/41305/ that's resolved too, so I think we'll have fixed this bug for good when https://git.opendaylight.org/gerrit/#/c/39982/10/ is merged.

Comment by Alexis de Talhouët [ 01/Aug/16 ]

beryllium --> https://git.opendaylight.org/gerrit/#/c/42646/1

Generated at Wed Feb 07 19:55:46 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.