Page 1 of 1

Machine is already locked for a session

Posted: 14. Dec 2012, 17:32
by BobKubista
Hi,

I'm trying to manipulate a linux VM (hosted on windows) via the VBox webservice. First I shutdown my VM, but when I want to change stuff on it with the webservice (and java), I get: The machine "X" is already locked for a session (or being unlocked). My code goes wrong when locking with the write locktype.

Anyone got any Idea's?

Code: Select all

LOGGER.info("connecting to VM");
		VirtualBoxManager manager = VirtualBoxManager.createInstance(null);
		manager.connect("http://localhost:18083", "", "");
		final IVirtualBox box = manager.getVBox();
		IMachine machine = box.findMachine("Linux");
		IStorageController controller = machine.getStorageControllerByName("Storage");
		
		ISession session = manager.getSessionObject();		
		machine.lockMachine(session, LockType.Write);
		IMachine openedMachine = session.getMachine();

Re: Machine is already locked for a session

Posted: 14. Dec 2012, 17:45
by noteirak
Would this bug be your problem?
If yes, just turn all your VM off, vboxwebsrv, wait 10 sec, turn vboxwebsrv back on and try again.