java dbus bindings and network manager issues
Greg DeAngelis
gdeangel at gmail.com
Wed Mar 11 09:19:00 PDT 2009
Hello all. I am having some problems when trying to use the java dbus
bindings to retrieve information from Network Manager and was hoping
for some feedback. I have attached a small sample to demonstrate these
issues. All line numbers refer to this unless noted.
When trying to retrieve a list of Paths from some dbus Properties
objects, such as the ActiveConnections property on line 33, I get a
list of ObjectPath objects. ObjectPath is package protected in the
library and thus not accessible. This class is also not cast-able to
the Path object. Temporarily I have been retrieving a list of Objects
and call toString() to get the path string but there is clearly a
return value parsing issue.
Exception in thread "main" java.lang.ClassCastException:
org.freedesktop.dbus.ObjectPath cannot be cast to
org.freedesktop.dbus.Path
at dbusnmtestapp.NMJavaDBusIssues.ActiveConnections(NMJavaDBusIssues.java:37)
at dbusnmtestapp.NMJavaDBusIssues.<init>(NMJavaDBusIssues.java:26)
at dbusnmtestapp.NMJavaDBusIssues.main(NMJavaDBusIssues.java:79)
When trying to retrieve the Connection property on line 67, which is
another Path, I get an exception. The problem here I believe is that
the Connection property on interface org.freedesktop.NetworkManager
exposed at an active connection path (ie
/org/freedesktop/NetworkManagerSettings/0) returns a Path that is
exposed either on org.freedesktop.NetworkManagerSystemSettings or
org.freedesktop.NetworkManagerUserSettings depending on whether the
connection is a system or user connection. I think the bindings are
trying to return a proxy object to a network manager connection on the
org.freedesktop.NetworkManager interface exposed at the returned path
which is always going to fail.
org.freedesktop.dbus.exceptions.DBusExecutionException: Wrong return
type (failed to de-serialize correct types: Failed to create proxy
object for /org/freedesktop/NetworkManagerSettings/0 exported by :1.6.
Reason: Could not find an interface to cast to )
at org.freedesktop.dbus.RemoteInvocationHandler.convertRV(Unknown
Source)
at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(Unknown
Source)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(Unknown Source)
at $Proxy1.Get(Unknown Source)
at dbusnmtestapp.NMJavaDBusIssues.getActiveConnection(NMJavaDBusIssues.java:67)
at dbusnmtestapp.NMJavaDBusIssues.ActiveConnectionsPathFix(NMJavaDBusIssues.java:55)
at dbusnmtestapp.NMJavaDBusIssues.<init>(NMJavaDBusIssues.java:26)
at dbusnmtestapp.NMJavaDBusIssues.main(NMJavaDBusIssues.java:79)
Network Manager uses a path of / to indicate a null value since dbus
lacks this type. This occurs in a few places in their dbus
architecture most notably when an interface does not have an active
dhcp configuration, when a connection does not point to a specific
object (wifi connections point to the accesspoint objects, wired
connections will have a /), and when a wifi interface is not
associated with an accesspoint. It appears that the java bindings do
not like this. I suspect this is another introspection failure because
the path does not exist.
org.freedesktop.dbus.exceptions.DBusExecutionException: Wrong return
type (failed to de-serialize correct types: Failed to create proxy
object for / exported by :1.6. Reason: Could not find an interface to
cast to )
at org.freedesktop.dbus.RemoteInvocationHandler.convertRV(Unknown
Source)
at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(Unknown
Source)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(Unknown Source)
at $Proxy1.Get(Unknown Source)
at dbusnmtestapp.NMJavaDBusIssues.getActiveConnection(NMJavaDBusIssues.java:69)
at dbusnmtestapp.NMJavaDBusIssues.ActiveConnectionsPathFix(NMJavaDBusIssues.java:55)
at dbusnmtestapp.NMJavaDBusIssues.<init>(NMJavaDBusIssues.java:26)
at dbusnmtestapp.NMJavaDBusIssues.main(NMJavaDBusIssues.java:79)
The only solution I have found thus far for the last two issues is to
remove the call to getExportedObject on line 430 of Marshalling.java
and just always construct the Path object. While I have yet to
encounter an issue in doing so, I'm hesitant towards calling this a
good solution. Perhaps the author can chime in here? Also note, the
first issue exists regardless of whether I make this change or not.
Thanks for your time and I apologize for the lengthy post.
Greg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NMJavaDBusIssues.java
Type: text/x-java
Size: 2966 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20090311/9dc065de/attachment.java
More information about the dbus
mailing list