Bluetooth Device is not ready. [1] Operation not permitted

1,426 views
Skip to first unread message

Stephen Feyrer

unread,
Jan 18, 2011, 7:02:23 PM1/18/11
to bluecov...@googlegroups.com
Hi.

I just tried to run the example OBEXPutServer on my Linux PC Bluez 4.80 (error message below).  I have read that to make the computer discoverable that you need to be root, why is this when running from my user account I can change the discoverability of my PC from a desktop app?

Is there a configuration of my system that I can change to affect this?

BlueCove version 2.1.1-SNAPSHOT on bluez
Exception in thread "main" javax.bluetooth.BluetoothStateException: Bluetooth Device is not ready. [1] Operation not permitted
at com.intel.bluetooth.BluetoothStackBlueZ.nativeSetLocalDeviceDiscoverable(Native Method)
at com.intel.bluetooth.BluetoothStackBlueZ.setLocalDeviceDiscoverable(BluetoothStackBlueZ.java:310)
at javax.bluetooth.LocalDevice.setDiscoverable(LocalDevice.java:206)
at OBEXPutServer.main(OBEXPutServer.java:14)
BlueCove stack shutdown completed


--
Kind regards

Stephen.

Mina Shokry

unread,
Jan 19, 2011, 8:56:50 AM1/19/11
to bluecov...@googlegroups.com
The desktop application may be using DBus. Bluecove-gpl module doesn't.
If you want to be able to change discoverability without being root, you may try bluecove-bluez module which depends on DBus.

see this http://code.google.com/p/bluecove/wiki/stacks

--
You received this message because you are subscribed to the Google Groups "bluecove-users" group.
To post to this group, send email to bluecov...@googlegroups.com.
To unsubscribe from this group, send email to bluecove-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bluecove-users?hl=en.

Stephen Feyrer

unread,
Jan 19, 2011, 10:11:18 AM1/19/11
to bluecov...@googlegroups.com
Hi,

Thanks for your quick reply!

The bluecove-bluez module results in the error below.

Exception in thread "main" java.lang.NoClassDefFoundError: org/freedesktop/dbus/exceptions/DBusException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.intel.bluetooth.BlueCoveImpl.loadStackClass(BlueCoveImpl.java:347)
at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:438)
at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1035)
at java.security.AccessController.doPrivileged(Native Method)
at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1033)
at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1026)
at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
at OBEXPutServer.main(OBEXPutServer.java:14)
Caused by: java.lang.ClassNotFoundException: org.freedesktop.dbus.exceptions.DBusException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 12 more

It is my desire to learn a little java and bluetooth networking.  Admittedly I didn't think combining the two would be easy but this is presenting more of a challenge than I expected.  What I had hoped to achieve was to write a small program that does something with Bluetooth and runs as well on Windows, Mac and Linux...  Could I be using the wrong tools?

I have looked at other bluetooth stacks for Java I have found a few that are commerical and don't seem to support bluez, the Sun JSR-82 implementation that is now defunct and others that didn't seem appropriate at the time.  What has happened to Bluecove development on source forge the files listed there were last updated in 2008? 

With Dbus-Java in the build-path I now get a new error.

Exception in thread "main" java.lang.NoClassDefFoundError: cx/ath/matthew/unix/UnixSocket
at com.intel.bluetooth.BluetoothStackBlueZDBus.requireNativeLibraries(BluetoothStackBlueZDBus.java:152)
at com.intel.bluetooth.BlueCoveImpl.loadNativeLibraries(BlueCoveImpl.java:380)
at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:440)
at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1035)
at java.security.AccessController.doPrivileged(Native Method)
at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1033)
at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1026)
at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
at OBEXPutServer.main(OBEXPutServer.java:14)
Caused by: java.lang.ClassNotFoundException: cx.ath.matthew.unix.UnixSocket
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 11 more


Please don't be under the mistaken impression that I might know what I'm doing (at least not yet).

--
Thanks,

Stephen.

Mina Shokry

unread,
Jan 19, 2011, 10:34:44 AM1/19/11
to bluecov...@googlegroups.com
there is still a missing library

This page may help you
http://www.bluecove.org/bluecove-bluez/index.html

Stephen Feyrer

unread,
Jan 19, 2011, 11:36:13 AM1/19/11
to bluecov...@googlegroups.com
Hi,

Thanks again.

Now I have new message:-

load [unix-java_x64] no unix-java_x64 in java.library.path
at com.intel.bluetooth.BlueCoveImpl.loadNativeLibraries(BlueCoveImpl.java:391)

at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:440)
at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1035)
at java.security.AccessController.doPrivileged(Native Method)
at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1033)
at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1026)
at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
at OBEXPutServer.main(OBEXPutServer.java:14)

Having installed libmatthew-java I now have /usr/lib64/libmatthew-java/libunix-java.so with reference to the above error I have created a symbolic link to the aforementioned file   That did not help.  Though I have read about the Unix Sockets Library where can it be found on line.

What am I missing?


--
Regards

Stephen

Mina Shokry

unread,
Jan 19, 2011, 11:47:14 AM1/19/11
to bluecov...@googlegroups.com
try running your program with this parameter passed to the "java" command "-Djava.library.path=/usr/lib64/libmatthew-java"

Stephen Feyrer

unread,
Jan 19, 2011, 1:09:36 PM1/19/11
to bluecov...@googlegroups.com
Hi,

I have yet another error to report:

Exception in thread "main" org.freedesktop.DBus$Error$UnknownMethod: Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.freedesktop.dbus.Error.getException(Error.java:110)
at org.freedesktop.dbus.Error.throwException(Error.java:140)
at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:136)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:188)
at $Proxy1.DefaultAdapter(Unknown Source)
at com.intel.bluetooth.BluetoothStackBlueZDBus.initialize(BluetoothStackBlueZDBus.java:275)
at com.intel.bluetooth.BlueCoveImpl.setBluetoothStack(BlueCoveImpl.java:964)
at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:493)

at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65)
at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1035)
at java.security.AccessController.doPrivileged(Native Method)
at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1033)
at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1026)
at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
at OBEXPutServer.main(OBEXPutServer.java:14)

If and or when indeed and depending upon if I ever get this example to work, having referenced "-Djava.library.path=/usr/lib64/libmatthew-java" at build time will that then require that library to be found in the same location on all other bluez platforms this runs on?


--
Thanks,

Stephen.

Mina Shokry

unread,
Jan 19, 2011, 1:12:20 PM1/19/11
to bluecov...@googlegroups.com
sorry, I haven't used this module before, I can't help more.

Stephen Feyrer

unread,
Jan 19, 2011, 1:56:28 PM1/19/11
to bluecov...@googlegroups.com
Hi again.

Thanks for all your help, may I ask you some more questions before I must find something else that sounds easyish at first only to turn out fiendishly difficult later on?

Do you know why there doesn't seem to have been much activity in the last year on Bluecove?

Do you know why you need to be root to change discoverability with Bluecove gpl?

Would you recommend an alternative bluetooth stack for Java?

--
Kind regards

Stephen.

Mina Shokry

unread,
Jan 19, 2011, 2:29:46 PM1/19/11
to bluecov...@googlegroups.com
Here are answers for your questions.


Do you know why there doesn't seem to have been much activity in the last year on Bluecove?
Because almost there is nothing new to be done. Just some issues need to be fixed.


Do you know why you need to be root to change discoverability with Bluecove gpl?
This is a requirement of BlueZ APIs. The native C function that changes discoverability doesn't work unless its caller has superuser privileges.


Would you recommend an alternative bluetooth stack for Java?
I think the most stable bluetooth stack for Java is Bluecove. If you find something better, please let us all know.

Stephen Feyrer

unread,
Jan 19, 2011, 5:22:08 PM1/19/11
to bluecov...@googlegroups.com
Hi.

Sorry, another question...
 
Do you know why you need to be root to change discoverability with Bluecove gpl?
This is a requirement of BlueZ APIs. The native C function that changes discoverability doesn't work unless its caller has superuser privileges.

As I mentioned before, my interest in this also about learning about Java, so may I ask how do you identify and call the C function in Java?

On the other hand I think the above calling of the C function might be as much a Bluez problem as it is a Bluecove problem.

Just to touch on the points raised by your answers to my other two questions.  For the first answer, brilliant, I like it!  For the other (third) question, the above issue a side, it's not very likely that I'll find anything better sorry.  If I do learn anything that I think might prove useful to you, I'll let you know.

Thank you for all your help.

--
Kind regards

Stephen.

Mina Shokry

unread,
Jan 20, 2011, 8:15:19 AM1/20/11
to bluecov...@googlegroups.com
To learn how to call a native C function from Java code, this link may be useful
http://java.sun.com/docs/books/jni/

Stephen Feyrer

unread,
Jan 20, 2011, 10:35:25 AM1/20/11
to bluecov...@googlegroups.com
Thanks.

I'll be reading that.


--
All the best.

Stephen.
Reply all
Reply to author
Forward
0 new messages