Wowza Community

GetAppInstance returns null!


What could be the possible reasons that:

public void onServerInit(IServer server)
		IVHost vhost = null;
		IApplication application = null;
		IApplicationInstance app = null;
		application = vhost.getApplication(appName);   // appName = "myApp"
		app = application.getAppInstance(appInstName);  //  appInstName = "_definst_"

This sequence would return app == null ?? The vhost is found (not null), the application is found (not null), but trying to get appInstance returns null. There are no errors reported by the startup log. (except that this variable is null). Once the server starts, the application works fine, only my code which depends upon it does not work.



Hi Atmapuri,

Do this first:

vhost.startApplicationInstance(appName, appInstName)


Try it like this, which works in my test:

public void onServerInit(IServer server) {
		IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
		IApplication application ;
		IApplicationInstance app ;
		while (true)
			application = vhost.getApplication("vod"); 
			if (!application.equals(null));
		app = application.getAppInstance("_definst_"); 


It turns out, if I dont try to debug the code mentioned (no breakpoint), then this line is not needed:

vhost.startApplicationInstance(appName, appInstName)

Somehow getAppInstance returns a valid object and everything works fine. Now I have put breakpoint after the getAppInstance. Is that usual behaviour?