title: How to overcome "Missing optionally imported package"issue in OSGi
body: <p>I wrote an OSGi bundle using "maven-bundle-plugin"(where i try to make the "jruby-complete-1.4.0.jar" as osgi bundle, note that only dependency is  "jruby-complete-1.4.0.jar")..When i check the bundle via osgi console using diag command( #diag XX) it says some packages are missing;</p>
  
  <pre><code>osgi&gt; diag 51
  reference:file:dropins/jruby-complete-1.4.0.wso2v1.jar [51]
    Direct constraints which are unresolved:
      Missing optionally imported package com.sun.mirror.apt_0.0.0.
      Missing optionally imported package com.sun.mirror.declaration_0.0.0.
      Missing optionally imported package com.sun.mirror.type_0.0.0.
      Missing optionally imported package com.sun.mirror.util_0.0.0.
      Missing optionally imported package org.apache.bsf.util_0.0.0.
      Missing optionally imported package org.jgrapht_0.0.0.
      Missing optionally imported package org.jgrapht.graph_0.0.0.
      Missing optionally imported package sun.misc_0.0.0.
  </code></pre>
  
  <p>My pom is like;</p>
  
  <pre><code>&lt;plugin&gt;
                  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
  
                  &lt;extensions&gt;true&lt;/extensions&gt;
                  &lt;configuration&gt;
                      &lt;instructions&gt;
                          &lt;Bundle-SymbolicName&gt;${project.artifactId}&lt;/Bundle-SymbolicName&gt;
                          &lt;Bundle-Name&gt;${project.artifactId}&lt;/Bundle-Name&gt;
                          &lt;Export-Package&gt;
                              com.kenai.*,
                              com.sun.jna.*,
                              org.jruby.*,
                              org.joni.*,                            
                          &lt;/Export-Package&gt;
                          &lt;Import-Package&gt;                
                          *;resolution:=optional
                          &lt;/Import-Package&gt;
                          &lt;Fragment-Host&gt;bsf-all&lt;/Fragment-Host&gt;
              &lt;DynamicImport-Package&gt;*&lt;/DynamicImport-Package&gt;    
              &lt;Embed-Dependency&gt;*;scope=compile|runtime;inline=true;&lt;/Embed-Dependency&gt;       
                      &lt;/instructions&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>So, i tried add those "optional missing packages"  in <code>&lt;Import-Package&gt;</code> option as in pom[2]
  But it gives more issues like;</p>
  
  <pre><code>ference:file:dropins/jruby-complete-1.4.0.wso2v1.jar [51]
  Constraints from the fragment conflict with the host: Import-Package: *; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.apt; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.declaration; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.type; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.util; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: javax.management; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: javax.script; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: javax.swing.plaf.basic; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: org.apache.bsf; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: org.apache.bsf.util; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: org.jgrapht; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: org.jgrapht.graph; version="0.0.0"
  Constraints from the fragment conflict with the host: Import-Package: org.jruby.anno; version="[1.4.0,2.0.0)"
  Constraints from the fragment conflict with the host: Import-Package: org.jruby.exceptions; version="[1.4.0,2.0.0)"
  Constraints from the fragment conflict with the host: Import-Package: org.jruby.runtime; version="[1.4.0,2.0.0)"
  Constraints from the fragment conflict with the host: Import-Package: org.jruby.runtime.builtin; version="[1.4.0,2.0.0)"
  Constraints from the fragment conflict with the host: Import-Package: sun.misc; version="0.0.0"
  Direct constraints which are unresolved:
    Missing imported package com.sun.mirror.apt_0.0.0.
    Missing imported package com.sun.mirror.declaration_0.0.0.
    Missing imported package com.sun.mirror.type_0.0.0.
    Missing imported package com.sun.mirror.util_0.0.0.
    Missing imported package org.apache.bsf.util_0.0.0.
    Missing imported package org.jgrapht_0.0.0.
    Missing imported package org.jgrapht.graph_0.0.0.
    Missing optionally imported package org.jruby.anno_[1.4.0,2.0.0).
    Missing optionally imported package org.jruby.exceptions_[1.4.0,2.0.0).
    Missing optionally imported package org.jruby.runtime_[1.4.0,2.0.0).
    Missing optionally imported package org.jruby.runtime.builtin_[1.4.0,2.0.0).
    Missing imported package sun.misc_0.0.0.  
  </code></pre>
  
  <p>pom.xml [2];</p>
  
  <pre><code> &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
  
                  &lt;extensions&gt;true&lt;/extensions&gt;
                  &lt;configuration&gt;
                      &lt;instructions&gt;
                          &lt;Bundle-SymbolicName&gt;${project.artifactId}&lt;/Bundle-SymbolicName&gt;
                          &lt;Bundle-Name&gt;${project.artifactId}&lt;/Bundle-Name&gt;
                          &lt;Export-Package&gt;
                              com.kenai.*,
                              com.sun.jna.*,
                              org.jruby.*,
                              org.joni.*,                            
                          &lt;/Export-Package&gt;
                          &lt;Import-Package&gt;                
                          com.sun.mirror.apt.*,
                          com.sun.mirror.declaration.*,
                          com.sun.mirror.type.*,
                          com.sun.mirror.util.*,
                          org.apache.bsf.util.*,
                          org.jgrapht.*,
                          org.jgrapht.graph.*,
                          sun.misc.*,
                            *;resolution:=optional
                          &lt;/Import-Package&gt;
                          &lt;Fragment-Host&gt;bsf-all&lt;/Fragment-Host&gt;
              &lt;DynamicImport-Package&gt;*&lt;/DynamicImport-Package&gt;    
              &lt;Embed-Dependency&gt;*;scope=compile|runtime;inline=true;&lt;/Embed-Dependency&gt;       
                      &lt;/instructions&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>How can i overcome above issue? 
  I'm exporting some packages which, i need for other bundles...Am i doing anything wrong here?</p>