title: Install the OSGi Bundle using the ByteArray
body: <p>I am trying to install an OSGi bundle in OSGi container. I have a jar file in one of my folder.. I read that jar file into <code>ByteArray</code> and then I am using this <code>ByteArray</code> to install the <code>Framework</code> bundle in OSGi container. Below is the code..</p>
  
  <pre><code>FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
  
  framework = frameworkFactory.newFramework(new HashMap&lt;String, String&gt;());
  framework.start();
  
  final String basePath = "C:\\LocalStorage";
  final BundleContext bundleContext = framework.getBundleContext();
  final List&lt;Bundle&gt; installedBundles = new LinkedList&lt;Bundle&gt;();
  
  String filename = "Framework" + "-" + "1.0.0" + ".jar";
  String localFilename = basePath+ File.separatorChar + filename;
  
  File file = new File(localFilename);
  byte [] fileData = new byte[(int)file.length()];
  DataInputStream dis = new DataInputStream((new FileInputStream(file)));
  dis.readFully(fileData);
  dis.close();
  
  // But below line gives me exception always-
  installedBundles.add(bundleContext.installBundle(filename, new ByteArrayInputStream(fileData)));
  
  for (Bundle bundle : installedBundles) {
      bundle.start();
  }
  </code></pre>
  
  <p>Below is the exception, I always get-</p>
  
  <pre><code>org.osgi.framework.BundleException: Bundle symbolic name and version are not unique: Framework:1.0.0
  </code></pre>
  
  <p>Can anyone tell me what wrong I am doing? And I need to use ByteArray because, in some of my code in another class, I am using ByteArray, so I need to pass the ByteArray of the jars file to those method..</p>
  
  <p><strong>Update:-</strong></p>
  
  <p>But if I am installing it like this, then it works fine. It doesn't works if I am installing it through ByteArray..</p>
  
  <pre><code>final String basePath = "C:\\LocalStorage";
  final BundleContext bundleContext = framework.getBundleContext();
  final List&lt;Bundle&gt; installedBundles = new LinkedList&lt;Bundle&gt;();
  
  String filename = "Framework" + "-" + "1.0.0" + ".jar";
  String localFilename = Constants.FILE_PROTOCOL + basePath+ File.separatorChar + filename;
  
  installedBundles.add(bundleContext.installBundle(localFilename));
  
  for (Bundle bundle : installedBundles) {
      bundle.start();
  }
  </code></pre>
  
  <p>It might be possible that I am doing something wrong with ByteArray thing? Any idea?</p>