Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Using bluecove with kura
Using bluecove with kura [message #1693271] Wed, 22 April 2015 19:10 Go to next message
Alex Yuu is currently offline Alex YuuFriend
Messages: 8
Registered: April 2015
Junior Member
Hello,
I've been banging my head against kura for the past few days trying to get bluecove to work alongside a serial port in kura. I can make both work individually without any issues but as soon as I try to try to use both I get one of two errors:

java.lang.LinkageError: loader constraint violation: when resolving interface method "org.osgi.service.io.ConnectionFactory.createConnection(Ljava/lang/String;IZ)Ljavax/microedition/io/Connection;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, mykurapkg/SerialConnection, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, org/osgi/service/io/ConnectionFactory, have different Class objects for the type ectionFactory.createConnection(Ljava/lang/String;IZ)Ljavax/microedition/io/Connection; used in the signature

-OR-

I get a null pointer returned when I try to use javax.microedition.io.Connector

The error depends on whether I include javax.microedition.io in the manifest file - the first error occurs if I do and the second issue occurs if I don't. The bluecove jar file includes a copy of javax.microedition.io, which might be causing the class loader error. The serial port code is based on the kura serial example. The project is being deployed on the Raspberry Pi. Any help would be greatly appreciated.
Re: Using bluecove with kura [message #1693294 is a reply to message #1693271] Wed, 22 April 2015 22:51 Go to previous messageGo to next message
Alex Yuu is currently offline Alex YuuFriend
Messages: 8
Registered: April 2015
Junior Member
Seems like the linkage error was caused by using the connection factory in a different class than it was instantiated in. However, I'm now facing a different but similar error. The full stacktrace is also included.

Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "javax/microedition/io/Connection"

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "javax/microedition/io/Connection"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:632)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:607)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.intel.bluetooth.Utils.class$(Utils.java:44)
at com.intel.bluetooth.Utils.<clinit>(Utils.java:44)
at javax.bluetooth.UUID.<init>(UUID.java:224)
at mykurapkg.BtConnection.<init>(BtConnection.java:46)
at mykurapkg.BtServer.activate(BtServer.java:50)
Re: Using bluecove with kura [message #1693414 is a reply to message #1693294] Fri, 24 April 2015 04:07 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello,

It is really difficult to tell what is happening without seeing your bundles. I saw you posted a link to your Github account in another post, is the code giving you trouble there? If so, I can take a look and see if I see any problems.

Thanks,
--Dave
Re: Using bluecove with kura [message #1693514 is a reply to message #1693414] Fri, 24 April 2015 16:10 Go to previous messageGo to next message
Alex Yuu is currently offline Alex YuuFriend
Messages: 8
Registered: April 2015
Junior Member
The code I posted on github earlier works fine. The issue seems to be integrating Kura with the bluecove jar files. I created an example bundle to demonstrate this issue on my repository: https://github.com/Morocat/BluetoothExample.git
The bundle is the "IssueExample" folder. At line 57 in ForMyIssue.java is a call to a bluecove class. Depending on whether we call that before or after opening the serial port we get different errors. Thanks for taking the time to help with this.
Re: Using bluecove with kura [message #1693521 is a reply to message #1693514] Fri, 24 April 2015 17:15 Go to previous message
Amit Kumar Mondal is currently offline Amit Kumar MondalFriend
Messages: 108
Registered: March 2015
Location: Munich, Germany
Senior Member

I am not quite sure about the Bluecove issue in Raspberry Pi as I haven't even deployed it to check but after having a look in the error log that you have pasted before seems to be a problem with creating StreamConnectionNotifier connection using Connector directly.

The Bluetooth Connection Factory implements the org.osgi.service.io.ConnectionFactory so as to be used through the OSGi IO Connector Service implemented by the Connector Service Bundle (Framework Module).

Have a glance at the code below.

public class BluetoothSPPServer extends Thread implements BundleActivator {

  private ServiceReference         connRef;
  private ConnectorService         connService;
  private StreamConnection         connection;
  private StreamConnectionNotifier server;
  private static final UUID _IDENTIFIER = new UUID("1101", true);
  private static final String URL = "btspp://localhost:" + _IDENTIFIER + ";name=BluetoothServer";
  
  public void start(BundleContext bc) {

    connRef = bc.getServiceReference(ConnectorService.class.getName());
    
    if (connRef != null) {
      connService = (ConnectorService)bc.getService(connRef);
      
      try {
        server = (StreamConnectionNotifier)connService.open(URL, 
                                                            ConnectorService.READ); 
      } catch(ConnectionNotFoundException ce) {
        ce.printStackTrace();
      } catch(IOException ioe) {
        ioe.printStackTrace(); 
      }
    }
    start();
  }
  
  public void run() {
    try {
      connection = server.acceptAndOpen();
      DataInputStream inputStream = connection.openDataInputStream();
      while(true) {
        String input = inputStream.readUTF();
        while(input != null) {
          System.out.println(input);
          input = inputStream.readUTF();
        }
      }      
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  
  public void stop(BundleContext bc) {
    try {
      connection.close();

    } catch(IOException ioe) {
      ioe.printStackTrace();
    }
    bc.ungetService(connRef);    
  }
}


Amit Kumar Mondal
Email: admin@amitinside.com
Skype: arsenalnerk Blog: blog.amitinside.com
Previous Topic:Eclipse Kura MQTT Security
Next Topic:Does Kura support Raspberry Pi 2 board?
Goto Forum:
  


Current Time: Fri Apr 26 07:53:10 GMT 2024

Powered by FUDForum. Page generated in 0.04227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top