Nullpointer exception from DaemonService

Hi all,

I implemented DaemonService from an example project where it’s working. After I implement it in the project I am currently working on I am met with a nullpointer exception upon running the ursim. Can anybody help me?

Here is the error:
java.lang.NullPointerException at com.ur.urcap.examples.mydaemonswing.impl.nodes.installation.MyDaemonInstallationNodeContribution$ ~[?:?] at ~[?:1.8.0_242]

This is the line that is throwing the error:

	private void start_python_program() {
		new Thread(new Runnable() {
			public void run() {
				daemonService.getDaemon().start();   <--- the line that is causing the nullpointer 

Here is my MyDaemonDaemonService class:

public class MyDaemonDaemonService implements DaemonService {

    private DaemonContribution daemonContribution;

    public MyDaemonDaemonService() {

    public void init(DaemonContribution daemonContribution) {
        this.daemonContribution = daemonContribution;
        try {
            daemonContribution.installResource(new URL("file:com/ur/urcap/CNC2HMI/_01_App/"));
        } catch (MalformedURLException e) {	}

    public URL getExecutable() {
        try {
            return new URL("file:com/ur/urcap/CNC2HMI/_01_App/"); // Python executables
        } catch (MalformedURLException e) {
            return null;

    public DaemonContribution getDaemon() {
        return daemonContribution;


I am not sure what is causing the nullpointer so any help is appreciated.

Best thing you can do to help track down nullpointers is to use System.out.println() and just start printing stuff to the terminal. My guess would be if you put (before the line that errors)


it’s going to print “null” to the terminal. If you still get a nullpointer, that means the .getDaemon() method is being inacted on a null object, so doing


would says null. Either the instance of daemonService never got initialized (by your activator I think) or the .getDaemon() method does not return an new instance of the daemon. Not totally sure how the init() function gets run. Maybe the service does that. Otherwise, looks like your “getDaemon()” method is just going to return null, since the variable daemonContribution was only ever declared, not initialized. (Again, unless something else runs the init() function that does the initializing.)

I maanged to track it down to the activator class where there a line was missing to register the daemonservice to the bundlecontext. Thanks for your input.