title: EJB with standalone client ignores persistence.xml (?)
body: <p>Please help, this is driving me crazy. I've been researching this for hours, and couldn't find an example that matches my situation.</p>
  
  <p>I'm writing a very simple Java EE App which authenticates users from a standalone client. 
  In Netbeans 7.3, I have a Java EE application project with an EJB module, an application client project, and a separate java class library for the bean's remote interface and the entities.</p>
  
  <p>The EJB module has one bean (AccountsBean.java), the class library project has the bean's remote interface (AccountsBeanRemote.java), the entity (Account.java) and the persistence.xml file. Here's a picture of the project layout so you can see it clearly: <a href="http://snag.gy/EoyQa.jpg" rel="nofollow">http://snag.gy/EoyQa.jpg</a></p>
  
  <p>I want to pass Account instances to the client.</p>
  
  <p>I'm using Glassfish 3.1 and Java DB (Derby). </p>
  
  <p>I have 3 databases: AccountsTest (which I want to use here), sample, and sun-appserv-samples (these two are created during the Glassfish install).</p>
  
  <p>The problem is that is doesn't matter what database connection I specify in persistence.xml, the table always gets created in the sample database sun-appserv-samples. It seems to me that the bean ignores the persistence.xml file. Maybe the problem is that persistence.xml is in a separate project from the bean, but this is the only way the IDE lets me do it if I want to pass Account instances to the remote client. </p>
  
  <p>Here's my persistence.xml: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
    &lt;persistence-unit name="LoginTest-libPU" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;class&gt;logintest.lib.Account&lt;/class&gt;
      &lt;properties&gt;
        &lt;property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/AccountsTest"/&gt;
        &lt;property name="javax.persistence.jdbc.password" value="app"/&gt;
        &lt;property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/&gt;
        &lt;property name="javax.persistence.jdbc.user" value="app"/&gt;
        &lt;property name="eclipselink.ddl-generation" value="create-tables"/&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>And AccountsBean.java: </p>
  
  <pre><code>@Stateless
  public class AccountsBean implements AccountsBeanRemote {
  
      @PersistenceContext(unitName = "LoginTest-libPU")
      EntityManager em;
  
      @Override
      public Account create(String name, String password) {
          ...
      }
  
      @Override
      public void remove(int id) {
          ...
      }
  
      @Override
      public boolean checkPassword(int id, String password) {
          ...
      }
  }
  </code></pre>
  
  <p>Account.java:</p>
  
  <pre><code>@Entity
  @Table(name = "ACCOUNTS")
  public class Account implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
      private String name;
      private String password;
  
      public Account() {
      }
  
      ...other methods
  </code></pre>
  
  <p>I guess I didn't configure the EntityManager correctly, but where should I put persistence.xml? If I put it in the EJB module, I also have to put the entities in the EJB module, and they will be inaccessible to the client.</p>
  
  <p>Thanks in advance!</p>