VIJava Browser – A Great Tool To Recommend!
While browsing the project home of VI Java API, I found a link to a great tool contributed by pitchcat. It is a standalone Java application that shows managed objects and data objects in a tree hierarchy, and all the methods attached to a managed object.
I highly recommend it to all the VI Java API developers. Why? Although you can get similar information from MOB, vijava browser gives you an overview of all the managed objects and clear paths to any managed objects or data objects.
Here are two screen shots:
Fig 1 Login Dialog
Fig 2 Main windows of the VIJava Browser
To download it, click here. VI Java API binary package is needed to run this application. If don’t have it yet, download it here.

Fails to browse the HostProfiles, from HostProfileManager.
Got the following exception.
Caused by: java.lang.ClassCastException: [Lcom.vmware.vim25.ManagedObjectReference; cannot be cast to [Lcom.vmware.vim25.mo.Profile;
at com.vmware.vim25.mo.ProfileManager.getProfile(ProfileManager.java:52)
Wrote a small code to test Profile[] getProfile call in HostProfilesManager. I get the same exception. is viJava broken for HostProfiles?
Thanks
V
private void testHostProfiles() {
HostProfileManager hpm = si.getHostProfileManager();
Profile[] profiles = hpm.getProfile(); // this call throws the exception.
for (Profile p : profiles) {
System.out.println(“Profile “+ p);
}
}
/*
* Method from ProfileManager.java
public Profile[] getProfile()
{
return (Profile[]) getCurrentProperty(“profile”); // this is the call in ProfileManager causing the exception.
}
*/
Hi Vishal,
This is a bug in vijava api. Could you please file a bug: https://sourceforge.net/tracker/?group_id=228007
Thanks!
Steve
Thanks Vishal for filing the bug: https://sourceforge.net/tracker/index.php?func=detail&aid=3040909&group_id=228007&atid=1073396. It’s fixed. Check the bug record for more info.
Steve
Hi Setve,
when I run this tools,it throw following error:
Exception occurred during event dispatching:
java.lang.InstantiationError: com.vmware.vim25.VimPortType
at com.vmware.vim25.mo.ServiceInstance.(ServiceInstance.java:82)
at com.vmware.vim25.mo.ServiceInstance.(ServiceInstance.java:69)
at vijavaBrowser.LoginDialog.onOk(LoginDialog.java:256)
I used this version vi java api:
vijava2120100715.jar
And I also have the same error when writing my own class when only invoke this constructor method:
public class newtest {
public static void main(String[] args) throws RemoteException, MalformedURLException {
ServiceInstance si = new ServiceInstance(new URL(“https://10.10.10.147/sdk”), “root”, “password”, true);
}
}
It is the same code as in the tool source code, I can not figure out why,can you help me? Cause if I can not have this “ServiceInstance” I can do nothing
Hi Yan,
It’s most likely a classpath issue with AXIS generated stub included in your classpath. Remove it and try again.
-Steve
Thanks Steve, for a quick fix, I am assuming i can pick it up in a patch release of 4.1.
One more question.
I see that when viClient reports events there is a type field {error|info|warning}, how do i get this info along with the event object, seems like event object doesnt have a severity or type field.
Thanks
Vishal
Hi Vishal,
I am going to GA the 2.1 very soon. You can either pick the source code from SVN right now or wait a little bit. I prefer the former because you can double check if the problem is solved. Please update the bug tracker upon validation.
As you said, the event object itself does not have field for the type, but the concrete event (subtypes of Event) does indicate something. For example, HostEnableAdminFailedEvent tells the nature of the event by its type name. Hope it helps.
Steve
Steve,
Any reason why the severity is skipped from the Event object? in our NMS tool we need to set the severity for each event, and i was planning to have it same as your Enum – EventEventSeverity. we are currently processing 87 Events, it would be tough to parse the event name to get the severity.
is it possible to add severity to the event object?
Thanks
Vishal
Hi Vishal,
Just wrote a comprehensive blog: http://www.doublecloud.org/2010/08/how-to-get-event-type-with-vsphere-api/. Hope you find it helpful.
Steve
Hi Steve,
You are right,my lib is messed up with a vim25 jar file from AXIS stub.
hi all,
who can tell me how to run this VIJava Browser? i run it that reported error of “java.lang.NullPointerException”.
semmy
hi all,
The VIJava Browser connect to vCenter or ESX ?
Both. Better yet, ESXi too.
Steve
Want to share the stack trace?
Steve
thanks Steve,
F:\application>java -cp . -jar vijavaBrowser.jar
Exception in thread “main” java.lang.NullPointerException
at vijavaBrowser.Application.main(Application.java:420)
the dom4j-1.6.1.jar and vijava2120100824.jar in current directory.
thanks again
@Steve Jin
After checking the src, I can guess why – it must be javac is null.
419 JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
420 JavaFileManager jfm = javac.getStandardFileManager(
As stated in the page in http://communities.vmware.com/docs/DOC-11934, “This sample required JDK(not JRE) 6 and VMware VI (vSphere) Java API.”
Most likely you were using JRE, or JDK for running this.
-Steve
hi Steve,
i solved it.i used the JRE to run it so appeared error.Thanks!
and I used VI Java API to develop application,but i don’t know how to traverse all vSwitch under the datacenter,not DistributedVirtualSwitch. and why have not the Managed Object of VirtualSwitch.
thanks again!
Semmy