# \[SOLVED\] \`DaemonContribution::start()\` always ends in \`ERROR\`

**URL:** <https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399>\
**Category:** URCaps SDK\
**Created:** [December 7, 2016, 5:39pm UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399 "2016-12-07T17:39:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon61104264](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon61104264](https://forum.universal-robots.com/u/anon61104264)\
**Post date:** [December 7, 2016, 5:39pm UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/1 "2016-12-07T17:39:40Z")

</div>

Hi all,

I have a problem when starting MyDaemon example.  
It turns out that when I click on the _start button_, the daemon ends in the **ERROR** state. Always. On the other hand, the `stop()` method works as expected.  
The following is the only documentation that I found about the `start()`:

> Start the daemon. Will be ignored if daemon is in ERROR state. When issuing multiple start and/or stop commands within a short time frame only the latest will be effectuated. If called when the daemon is in the INITIALIZING state it will be invoked when the daemon is ready (unless it enters the ERROR state).

I would like to understand _what_ could cause the **ERROR** state and _why_.

I am going to add some details in the following days.  
Thank you for your time.

Alessandro Tondo @qbrobotics

---

<div class="post-metadata">

**Author:** ![anon61104264](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon61104264](https://forum.universal-robots.com/u/anon61104264)\
**Post date:** [December 12, 2016, 9:58am UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/2 "2016-12-12T09:58:56Z")

</div>

I am sorry for the delay, but it was holiday in Italy.

I have tried to go into the deep and inspect the Java stack trace using `Thread.currentThread().getStackTrace()` from `MyDaemonDaemonService.getExecutable()`, which appears to be the one involved in the **ERROR** state setting.  
Here is what I get when clicking on the _start button_:

```
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.getDaemonIdentifier(RUNITService.java:213)
com.ur.urcap.servicedaemon.impl.RUNITService.getSymLinkPath(RUNITService.java:209)
com.ur.urcap.servicedaemon.impl.RUNITService.isRunning(RUNITService.java:173)
com.ur.urcap.view.impl.DaemonImpl.getState(DaemonImpl.java:81)
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getDaemon(MyDaemonDaemonService.java:59)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

```

The first `DaemonImpl.getState()` returns correctly in the **STOPPED** state.  
Then, `MyDaemonDaemonService.getExecutable()` is called three times consecutively by `DaemonImpl.start()`, where it seems to retrieve and check the executable path and hash code:

```
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.getDaemonIdentifier(RUNITService.java:213)
com.ur.urcap.servicedaemon.impl.RUNITService.getSymLinkPath(RUNITService.java:209)
com.ur.urcap.servicedaemon.impl.RUNITService.start(RUNITService.java:142)
com.ur.urcap.view.impl.DaemonImpl.start(DaemonImpl.java:70)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutablePath(RUNITService.java:203)
com.ur.urcap.servicedaemon.impl.RUNITService.start(RUNITService.java:148)
com.ur.urcap.view.impl.DaemonImpl.start(DaemonImpl.java:70)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.start(RUNITService.java:148)
com.ur.urcap.view.impl.DaemonImpl.start(DaemonImpl.java:70)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:189)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

```

Lastly, the following `DaemonImpl.getState()` returns in the infamous **ERROR** state (which persists until the _stop button_ is clicked):

```
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getExecutable(MyDaemonDaemonService.java:31)
com.ur.urcap.view.impl.DaemonImpl.getExecutable(DaemonImpl.java:41)
com.ur.urcap.servicedaemon.impl.RUNITService.getExecutableHashCode(RUNITService.java:217)
com.ur.urcap.servicedaemon.impl.RUNITService.getDaemonIdentifier(RUNITService.java:213)
com.ur.urcap.servicedaemon.impl.RUNITService.getSymLinkPath(RUNITService.java:209)
com.ur.urcap.servicedaemon.impl.RUNITService.isRunning(RUNITService.java:173)
com.ur.urcap.view.impl.DaemonImpl.getState(DaemonImpl.java:81)
com.ur.urcap.cpp.impl.MyDaemonDaemonService.getDaemon(MyDaemonDaemonService.java:59)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.awaitDaemonRunning(MyDaemonInstallationNodeContribution.java:191)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.applyDesiredDaemonStatus(MyDaemonInstallationNodeContribution.java:176)
com.ur.urcap.cpp.impl.MyDaemonInstallationNodeContribution.onStartClick(MyDaemonInstallationNodeContribution.java:68)

```

* * *

I know that this is a bit hard to read, but I cannot figure out how to get rid of this problem and I have almost tried everything I know.

For the sake of completeness, I am using `sdk-1.0.0-23` and `ursim-3.3.3` on Ubuntu 16.04 (but we have tried also with Ubuntu 14.04) and the `urtool3` is properly installed (checked with `dpkg -s urtool3`).

The _HelloWorld_ example obviously works as expected, like the _Screwing URCap_ does. The problem is with the _MyDaemon_ and with a simplified version of it where I tried to remove all the unnecessary elements.

Have you got any hints?

Thank you very much for your time,  
Alessandro Tondo @qbrobtoics

* * *

**Further Investigation:**  
The communication through RPC works like a charm if the executable is opened in a separate termianl. Nonetheless the initialization of the daemon seems not to be able to start the executable: I even modified the file permissions manually to make it executable by every user in the PC (`chmod a+x file.py`), but it is still not working it and continues to end in the **ERROR** state.

---

<div class="post-metadata">

**Author:** ![anon61104264](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon61104264](https://forum.universal-robots.com/u/anon61104264)\
**Post date:** [December 13, 2016, 2:58pm UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/3 "2016-12-13T14:58:42Z")

</div>

I have searched a bit more and I have found the `urcap_tutorial.pdf` in the sdk documentation, which says:

> The `/etc/service` directory contains links to the URCap daemon executables currently running. If a daemon executable has a link present but is in fact not running, the **ERROR** state will be returned upon querying the daemon’s state. _[…]_ Log information with respect to the process handling of the daemon executable are saved together with the daemon executable (follow the symbolic link of the daemon executable in `/etc/serice` to locate the log directory).

I was hopeful to find the solution there, but as you could imagine the directory `/etc/service` stays empty before, during and after the execution of the URCap in the simulator. Nonetheless, it could not be otherwise since `start-ursim.sh` requires no root privileges.

I have also tried with `sudo ./start-ursim.sh`, but the simulator stuck on startup while searching something that it cannot find as root.

Could be a problem of privileges?  
Does anyone has the same problem?

Alessandro Tondo @qbrobotics

---

<div class="post-metadata">

**Author:** ![anon87661449](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@anon87661449](https://forum.universal-robots.com/u/anon87661449)\
**Post date:** [December 13, 2016, 4:21pm UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/4 "2016-12-13T16:21:35Z")

</div>

Is runit correctly installed? Should be done by the `install.sh`, but sometimes the the installer quits before executing `installDaemonManager()` (e.g. when the java version check fails). If your `/etc/service` directory ist empty I would check this (there should exist a symlink pointing to `/etc/runit/runsvdir-ursim-3.3.3`)

---

<div class="post-metadata">

**Author:** ![anon61104264](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon61104264](https://forum.universal-robots.com/u/anon61104264)\
**Post date:** [December 14, 2016, 10:26am UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/5 "2016-12-14T10:26:31Z")

</div>

Thank you very much @anon87661449!

As you pointed out `runit` **was not installed at all** , probably because when I installed the simulator, the script crashed without advertise the failure.

I don’t know exactly what was wrong the first time but I’m going to describe here all the modifications that I have done to properly install the simulator and the SDK on Ubuntu 16.04.

Thank you again and hope this helps,  
Alessandro Tondo @qbrobotics

* * *

#### Install URsim PolyScope `3.3.3.292` on Ubuntu 16.04

1. open the `install.sh` in the `ursim-3.3.3` directory;

2. `openjdk-6-jre` is no more supported on Ubuntu 16.04; switch to `openjdk-8-jre` by renaming the proper field of `commonDependencies` (I cannot say that this has no drawbacks, it seems to work well though):

3. change the java version control accordingly (note the `1.8.0` instead of the `1.6.0`):

4. **[optional]** if you have installed a non-english Ubuntu, probably your desktop directory is not called `~/Desktop`. In such a case use something like this when creating the executable shortcuts or simply rename the path with your desktop directory name:

5. you are almost done, just open a terminal and type `./install.sh`;

6. **[optional]** if you have previously installed the URCaps SDK, you might force the dependencies installation with something like `apt-get install -f`;

7. **[optional]** if you get stuck like me while installing `runit`, please follow [this topic](http://askubuntu.com/questions/654951/failed-to-connect-to-socket-com-ubuntu-upstart-connection-refused-errors-were/665742#665742). In brief, you have to comment out the final part of `/var/lib/dpkg/info/runit.postinst` because it tries to call `upstart` which is no longer used in the newer Ubuntu releases, and than simply force the installation process (i.e. `sudo apt-get install -f`);

8. **[optional]** if you get stuck on point **7** , simply rerun `./install.sh` again;

9. if everything goes as expected you will find three executable shortcuts on your desktop.

#### Install URCaps SDK `1.0.0.23` on Ubuntu 16.04

1. open the `install.sh` in the `sdk-1.0.0-23` directory;

2. **[optional]** if you have previously installed the simulator, you might force the debian installation at the end of the installer (i.e. use `--force-all`):

3. **[important]** check if the debian package has been installed correctly through `dpkg -s urtool3`. It should prompt something like this (be sure that the status is **`Status: install ok installed`** ):

* * *

_Disclaimer: THESE MODIFICATIONS ARE PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._

---

<div class="post-metadata">

**Author:** ![anon46802796](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@anon46802796](https://forum.universal-robots.com/u/anon46802796)\
**Post date:** [May 29, 2017, 11:57am UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/6 "2017-05-29T11:57:05Z")

</div>

@anon61104264 your work and your summary post was more than useful and great for me. Thank you

Matteo Timossi @anon46802796

---

<div class="post-metadata">

**Author:** ![anon6555566](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@anon6555566](https://forum.universal-robots.com/u/anon6555566)\
**Post date:** [September 20, 2018, 12:35am UTC](https://forum.universal-robots.com/t/solved-daemoncontribution-start-always-ends-in-error/399/7 "2018-09-20T00:35:58Z")

</div>

hi, I hava a problem when starting start-ursim3.6

Use ‘apt autoremove’ to remove them.  
0 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.  
(Reading database … 297655 files and directories currently installed.)  
Preparing to unpack …/curl-dev-ur\_7.18.2-1\_amd64.deb …  
Unpacking curl-dev-ur (7.18.2-1) …  
dpkg: error processing archive /home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/curl-dev-ur\_7.18.2-1\_amd64.deb (–install):  
trying to overwrite ‘/opt/urtool-3.0/share/man/man3/curl\_multi\_info\_read.3’, which is also in package urtool3 0.3  
dpkg-deb (subprocess): decompressing archive member: internal gzip write error: Broken pipe  
dpkg-deb (subprocess): cannot copy archive member from ‘/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/curl-dev-ur\_7.18.2-1\_amd64.deb’ to decompressor pipe: failed to write (Broken pipe)  
dpkg-deb: error: subprocess returned error exit status 2  
Preparing to unpack …/libxmlrpc-c-dev-ur\_1.33.14\_amd64.deb …  
Unpacking libxmlrpc-c-dev-ur (1.33.14) …  
dpkg: error processing archive /home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-dev-ur\_1.33.14\_amd64.deb (–install):  
trying to overwrite ‘/opt/urtool-3.0/include/xmlrpc-c/abyss.h’, which is also in package urtool3 0.3  
dpkg-deb (subprocess): decompressing archive member: internal gzip write error: Broken pipe  
dpkg-deb (subprocess): cannot copy archive member from ‘/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-dev-ur\_1.33.14\_amd64.deb’ to decompressor pipe: failed to write (Broken pipe)  
dpkg-deb: error: subprocess returned error exit status 2  
Preparing to unpack …/libxmlrpc-c-ur\_1.33.14\_amd64.deb …  
Unpacking libxmlrpc-c-ur (1.33.14) …  
dpkg: error processing archive /home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-ur\_1.33.14\_amd64.deb (–install):  
trying to overwrite ‘/opt/urtool-3.0/lib/libxmlrpc\_server.so.3.33’, which is also in package urtool3 0.3  
dpkg-deb (subprocess): decompressing archive member: internal gzip write error: Broken pipe  
dpkg-deb (subprocess): cannot copy archive member from ‘/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-ur\_1.33.14\_amd64.deb’ to decompressor pipe: failed to write (Broken pipe)  
dpkg-deb: error: subprocess returned error exit status 2  
Errors were encountered while processing:  
/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/curl-dev-ur\_7.18.2-1\_amd64.deb  
/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-dev-ur\_1.33.14\_amd64.deb  
/home/ur/ursim/ursim-3.6.0.30512/ursim-dependencies/libxmlrpc-c-ur\_1.33.14\_amd64.deb
