title: persistence.xml - Error parsing XML: XML InputStream(1) Premature end of file
body: <p>I am getting this error when i'm trying to create an entity manager in my code.</p>
  
  <pre><code>EntityManagerFactory emf = Persistence.createEntityManagerFactory("puDS1", myproperties);
  </code></pre>
  
  <p>Any hints on why this could be happening? My persistence.xml seems to be a valid xml. </p>
  
  <pre><code>ERROR [main] (PersistenceXmlLoader.java:251) - Error parsing XML: XML InputStream(1) Premature end of file.
  javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
          at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
          at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
  Caused by: org.xml.sax.SAXParseException: Premature end of file.
          at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
          at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
          at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:70)
          at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:89)
          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:222)
          ... 4 more
  </code></pre>
  
  <p>THe persistence xml looks like this. Please note that i use maven resource filtering on this persistence.xml, so during compile time ${jar_file_name_ds1} and ${jar_file_name_ds2} is replaced with valid names. I have validated that the final persistence.xml has the values substituted properly. I don;t know if maven resource filtering is messing things up.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence 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" version="2.0"&gt;
      &lt;persistence-unit name="puDS1" transaction-type="RESOURCE_LOCAL"&gt;
        &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
        &lt;jar-file&gt;${jar_file_name_ds1}&lt;/jar-file&gt;      
        &lt;properties&gt;         
           &lt;property name="hibernate.max_fetch_depth" value="3"/&gt;
        &lt;/properties&gt;
     &lt;/persistence-unit&gt;   
     &lt;persistence-unit name="puDS2" transaction-type="RESOURCE_LOCAL"&gt;
        &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
        &lt;jar-file&gt;${jar_file_name_ds2}&lt;/jar-file&gt;
        &lt;properties&gt;
           &lt;property name="hibernate.max_fetch_depth" value="3"/&gt;
        &lt;/properties&gt;
     &lt;/persistence-unit&gt;   
  &lt;/persistence&gt;
  </code></pre>