Error connecting VirtualBoxManager with Web Service (Java)

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
tirimao
Posts: 3
Joined: 30. Sep 2016, 12:36

Error connecting VirtualBoxManager with Web Service (Java)

Post by tirimao »

Virtualbox version = 5.0.26
Virtualbox API version = 5_0
Connection type =Webserver
Language used = Java
OS = OS X 10.11.6

Hi there! I'm encountering a problem trying to connect my Java program to the local VBox web server. (Note: I obviously already started the vboxwebsrv)
This is the error occured:

Code: Select all

org.virtualbox_5_0.VBoxException: Connect doesn't make sense for local bindings
	at org.virtualbox_5_0.VirtualBoxManager.connect(VirtualBoxManager.java:51)
	at utils.TestVBox.main(TestVBox.java:243)
Cannot connect, start webserver first!
I simply tried to establish a connection to the local web server as stated in SDKref pdf and in the sample code (TestVBox.java shipped with SDK):

Code: Select all

private VirtualBoxManager vboxm= null;
	final String location = localLoc
	String username = null;
	String password = null;
vboxm = VirtualBoxManager.createInstance(null);
      
           try {
               vboxm.connect(location, username, password);
           } catch (VBoxException e) {
               e.printStackTrace();
               System.out.println("Cannot connect, start webserver first!");
           }
        
I tried to use even the TestVBox program (passing as parameter -w ) and same error occurs.
It seems like I'm doing something wrong, anyone could help me?
Is there anyone who use the local VBox Java web server, and how?
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Error connecting VirtualBoxManager with Web Service (Java)

Post by noteirak »

tirimao wrote:org.virtualbox_5_0.VBoxException: Connect doesn't make sense for local bindings
This error means you are using the XPCOM bindings and trying to connect to the WebServices. You need to use the WebServices bindings instead.
Use the following file (path relative to the ZIP root):

Code: Select all

/sdk/bindings/webservice/java/jax-ws/vboxjws.jar
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
tirimao
Posts: 3
Joined: 30. Sep 2016, 12:36

Re: Error connecting VirtualBoxManager with Web Service (Java)

Post by tirimao »

Sorry noteirak, I didn't mention the class paths I used.
vboxjws.jar (file you mentioned) was already in my classpath, so the error still persist and I don't know what I'm doing wrong.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Error connecting VirtualBoxManager with Web Service (Java)

Post by noteirak »

Then you most likely have another binding in your classpath as well. Make sure only one binding is included - the WebServices one.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
tirimao
Posts: 3
Joined: 30. Sep 2016, 12:36

Re: Error connecting VirtualBoxManager with Web Service (Java)

Post by tirimao »

Well Thank you for your Help!
I added time ago the xpcom binding in general Java class path and then forgot it so even adding the path to the web service jar, my program was forced to use the wrong binding. Now all seems to be OK!
Thanks you a lot!
Post Reply