java-systemd icon indicating copy to clipboard operation
java-systemd copied to clipboard

java-systemd not compatible with dbus-java v5

Open mbaudier opened this issue 1 year ago • 1 comments

With the latest major release of dbus-java (v5.0.0), Systemd.get().getManager() fails with:

java.lang.NoSuchMethodError: org/freedesktop/dbus/connections/impl/DBusConnection.getConnection(Lorg/freedesktop/dbus/connections/impl/DBusConnection$DBusBusType;)Lorg/freedesktop/dbus/connections/impl/DBusConnection; (loaded from xxxxxxx/org.freeedesktop.dbus.5.0.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@99aa01a5[org.freeedesktop.dbus:5.0.0(id=183)]) called from class de.thjom.java.systemd.Systemd (loaded from xxxxxxxxx/de.thjom.java.systemd.2.1.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@3fb8805f[de.thjom.java.systemd:2.1.0(id=204)]).
	de.thjom.java.systemd.Systemd.open(Systemd.java:164)
	de.thjom.java.systemd.Systemd.get(Systemd.java:116)
	de.thjom.java.systemd.Systemd.get(Systemd.java:105)
	...

Apparently the DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM) method has been removed.

I had the same issue with some low-level code which uses dbus-java directly, and it worked by using: DBusConnection dBusConnection = DBusConnectionBuilder.forSystemBus().build() instead.

mbaudier avatar Apr 10 '24 06:04 mbaudier

Thanks for sharing this, I might have a look into it, if I find the time. :/

thjomnx avatar Apr 12 '24 13:04 thjomnx