title: Karaf 4.1 - How to add DynamicImport-Package tag within a third party osgi jar bundle?
body: <p>I have a problem in the execution of a own bundle within Karaf 4.1, I am using Shiro for to persist users sessions, but when I recover the saved session, I have got an exception as:</p>
  
  <blockquote>
  <pre><code>Caused by: java.lang.ClassNotFoundException: io.twim.models.User
  </code></pre>
    
    <blockquote>
  <pre><code>at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:?]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:?]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
      at org.apache.felix.framework.BundleWiringImpl.doImplicitBootDelegation(BundleWiringImpl.java:1782) ~[?:?]
      at org.apache.felix.framework.BundleWiringImpl.searchDynamicImports(BundleWiringImpl.java:1717) ~[?:?]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1552) ~[?:?]
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79) ~[?:?]
  </code></pre>
    </blockquote>
  </blockquote>
  
  <p>I understand the problem in my case Shiro is executing a (cast) deserializing the persisted session object but within Shiro's ClassLoader there is no my class io.twim.models.User. My karaf instance have installed this bundles:</p>
  
  <blockquote>
  <pre><code>karaf@twim()&gt; list
  START LEVEL 100 , List Threshold: 50
  ID │ State  │ Lvl │ Version             │ Name
  ───┼────────┼─────┼─────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  51 │ Active │  80 │ 3.1.0               │ DataStax Java Driver for Apache Cassandra - Core
  52 │ Active │  80 │ 19.0.0              │ Guava: Google Core Libraries for Java
  73 │ Active │  50 │ 2.16.1              │ camel-blueprint
  83 │ Active │  80 │ 1.3.0               │ Apache Shiro :: Core
  86 │ Active │  80 │ 1.0.0.SNAPSHOT      │ twim-cache :: Distributed cache for TWIM
  87 │ Active │  80 │ 1.0.0.SNAPSHOT      │ twim-cassandra :: Implementation Cassandra to TWIM
  88 │ Active │  80 │ 1.0.0.SNAPSHOT      │ twim-common :: Bundle utility for all models, utilities, constants
  89 │ Active │  80 │ 1.0.0.SNAPSHOT      │ twim-core-model :: Bundle utility for all models used in TWIM
  90 │ Active │  80 │ 1.0.0.SNAPSHOT      │ twim-db :: Utilitaries to persitence into TWIM
  91 │ Active │  80 │ 1.0.0.SNAPSHOT      │ twim-jaas :: JAAS authentication module for TWIM
  </code></pre>
  </blockquote>
  
  <p>I need to add the tag DynamicImport-Package at the bundle 83:</p>
  
  <blockquote>
  <pre><code>83 │ Active │  80 │ 1.3.0               │ Apache Shiro :: Core
  </code></pre>
  </blockquote>
  
  <p>Executing <em>dynamic-import</em> command within karaf, I have fixed this problem:</p>
  
  <blockquote>
  <pre><code>karaf@twim()&gt; dynamic-import 83
  </code></pre>
  </blockquote>
  
  <p>But I would like to do this automatically in my feature installer, adding this tag <em>DynamicImport-Package: io.twim.models</em>, now I have my features.xml like this:</p>
  
  <pre><code>&lt;feature name="twim-auth" version="${project.version}"&gt;
      &lt;feature&gt;twim-cassandra&lt;/feature&gt;
      &lt;bundle&gt;mvn:org.apache.shiro/shiro-core/1.3.0&lt;/bundle&gt;
  
      &lt;bundle&gt;mvn:io.twim/twim-core-model/${project.version}&lt;/bundle&gt;
      &lt;bundle&gt;mvn:io.twim/twim-jaas/${project.version}&lt;/bundle&gt;
  &lt;/feature&gt;
  </code></pre>
  
  <p>How can I do this within my features.xml?</p>