title: JPA EclipseLink and dynamic Jar-Files
body: <p>I have an Application using JPA. In The application i have a class</p>
  
  <pre><code>@Entity
  public class Root{
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;
    ...
  }
  </code></pre>
  
  <p>in my <code>persistence.xml</code> i specified</p>
  
  <pre><code>&lt;persistence ...&gt;
    &lt;persistence-unit ...&gt;
      &lt;exclude-unlisted-classes&gt;false&lt;/exlude-unlisted-classes&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>Additional to that i have several Jar-Files which are loaded as Plugins at Runtime. These Plugins may have Classes extending the <code>Root</code> class, and which are also Entities.</p>
  
  <p>Loading the files works fine, but on persisting i get an <code>IllegalArgumentException</code> with the message <code>Subclass is not a known Entity type</code>. I read about the CompositePersistenceUnits, which are not really a solution, because i have to specify all the jar-files beforehand, which is not really possible with a plugin-based system.</p>
  
  <p>My Question is now:
  Can i dynamically add Jar-Files to a composite persistence unit? Or can i even add new Entities to a persistence unit which is not composite?</p>