title: Persistence unit name issue during deployment WildFly
body: <p>Stuck with some issue with my persistence module. </p>
  
  <p>getting error like <strong><em>"Unexpected problem gathering statistics: java.lang.IllegalStateException: JBAS011477: Persistence unit 'EAR_FileName.ear/EJB_Module_Persistence.jar#MyPersistenceUnit' is not available"</em></strong></p>
  
  <p>my persistence.xml file is located as highlighted below. please correct me if i am wrong - as per packaging structure persistence unit name starting with <em>EAR file name then my persistence module name then #unit name</em>,  which is absolutely right. and i am injecting my persistence unit in another ejb using PersistenceContext.</p>
  
  <pre><code>@PersistenceContext(unitName="MyPersistenceUnit")
  private EntityManager em;
  </code></pre>
  
  <p>could anyone suggest me what wrong i am doing here. i would appreciate any input/help you could provide on this. </p>
  
  <p>here is below module structure of my project</p>
  
  <pre><code>EAR_FileName.ear
        |
        |---EJB_Module1.jar
        |
        |---EJB_Module_Persistence.jar
                      |
                      |---META-INF
                            |
                            |---persistence.xml
  </code></pre>
  
  <p>Here is my persistence.xml file</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="MyPersistenceUnit" transaction-type="JTA"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
          &lt;jta-data-source&gt;java:/MyTransactionDS&lt;/jta-data-source&gt;
          &lt;class&gt;all class&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.show_sql" value="false"/&gt;
                  &lt;property name="hibernate.format_sql" value="true"/&gt;
              &lt;property name="hibernate.use_sql_comments" value="true"/&gt;
              &lt;property name="hibernate.cache.use_second_level_cache" value="true"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>P.S. using WildFly 8.1 as an application server.</p>
  
  <p>thanks in advance.  </p>