NullPointerException error confirmation.

I am getting a 'NullPointer Exception' on executing a 3rd Party code.

It has a class called Controller(which has a static method that returns an instance of the class).

publicclass Controller

{

privatestatic Controller instance;

publicstatic Controller getInstance()

{

return instance;

}

publicstaticvoid main(String[] args)throws Exception

{

String sz_runcommand ="Controller START/STOP userdefined_config_file";

instance =new Controller(args[1]);

if (args[0].equals("START"))

{

instance.start();

}

elseif (args[0].equals("STOP"))

{

instance.stop();

}

}

}

The Controller class is then being used in a different class :

publicclass InternalClient{

//.....

NodeList nodes = Controller.getInstance().getConfig().getNodeList("/Configuration/*");

}

I am sure that 'NullPointerException' is due to Controller.getInstance().getConfig().getNodeList() used above will return 'null' as

when the Controller class is loaded,the static method getInstance() is executed first and returns null.

Am I correct in the above?

Even after instantiating the Controller class,it returns NULL.

[2291 byte] By [bhuru_luthriaa] at [2007-11-27 0:49:43]
# 1

if the NPE is being thrown on this line

NodeList nodes = Controller.getInstance().getConfig().getNodeList("/Configuration/*");

as you seem to suggest, it could be any number of causes. break that line down into steps, and see what is coming back as null. eg (I'm guessing at some type names here)

Controller controller = Controller.getInstance();

Config config = controller.getConfig();

NodeList nodes = config.getNodeList("/Configuration/*");

that will help you pin down exactly what is null. where you go from there is another matter, though....

georgemca at 2007-7-11 23:19:25 > top of Java-index,Java Essentials,Java Programming...
# 2
I can't see there is a Controller constructor that takes a String arguement. I am wondering why it can compile?
Icycoola at 2007-7-11 23:19:25 > top of Java-index,Java Essentials,Java Programming...
# 3
> I can't see there is a Controller constructor that> takes a String arguement. I am wondering why it can> compile?String array, and the complete code certainly will compile. But why post that entire stuff? Especially since it has nothing to do with the
CeciNEstPasUnProgrammeura at 2007-7-11 23:19:25 > top of Java-index,Java Essentials,Java Programming...