I really don’t know how to explain this error properly…
It started when I added this method to my controller class:
public void loadPlayerComboBox() {
try{
final PreparedStatement collectPlayerNames =
ConnectionManager.getConnection().prepareStatement("SELECT "+PLAYER_NAME+" FROM PLAYERS");
final ResultSet playerNameResults = collectPlayerNames.executeQuery();
while(playerNameResults.next()){
IViewManager.Util.getInstance().getMyContainerPane().getMyPlayerManagerPane().getPlayerNameList()
.add(playerNameResults.getString(PLAYER_NAME));
}
}catch(final SQLException e){
System.out.println("SQLException. Reason: " + e.getMessage());
}
}
And I’ve confirmed that without this method (which is called on by a class, on start up of the program) I don’t have an error.
My error? When I run from eclipse, the programe starts to load the top bar of the frame appears, but the actual content doesn’t.

As well as this there is a strange drowing empty box, that I believe is caused by multiple processes being started up.
This, I beleive was caused by a stack overflow, as my getInstance() methods recursively called each other. I can’t get the stacktrace back for some reason, and at the moment the debug screen is just blank. I’ve checked my .log and it doesn’t have an error corresponding to that time stamp. I don’t know how they could call each other though. Here is the ViewManager method:
static class Util {
static private IViewManager viewManager = null;
static public synchronized IViewManager getInstance() {
if (viewManager == null) {
viewManager = new ViewManager();
}
return viewManager;
}
}
And the constructor:
public ViewManager(){
super("Tony Larp DB Manager");
this.setVisible(true);
this.setDefaultCloseOperation(3);
myContainerPane = new ContainerPane();
myContentMenu = new ContentMenu();
IController.Util.getInstance();
IPlayerCharacterManager.Util.getInstance();
this.setJMenuBar(myContentMenu);
this.getContentPane().add(myContainerPane);
this.pack();
}
The IController.Util.getInstance() method is identical, except the names of the class and objects it calls are different. Double checked locking just causes the first instance of IViewManager.getInstance() in my launcher to return a null pointer, this is at the start of the synchronised block.
To clarify, the programme calls IViewManager.Util.getInstance() the first time in the launcher, then it calls IController.Util.getInstance() for the first time in the above constructor. After that all calls to it should just return instances.
What would cause this sort of error? How can I even start to fix it?
This sort of behaviour shows you’ve got some sort of infinite loop. Some where you’ve crossed your threads (one method in a thread calls the a method in the other other, which calls the first).
Neither finishes constructing so your singletons don’t have an instance to call. Instead they keep trying to instantiate each other ad infinitum. Go back and rethink how seperate your singleton code threads are.