title: Tomcat 7 (JBoss EWS 2.0) + MySQL 5.1 + Hibernate - OpenShift - No persistence unit found
body: <p>Every time I try to reach my app on OpenShift I receive the "No Persistence provider for EntityManager named appname" error.</p>
  
  <p>I have been struggling to resolve this problem for two consecutive days and I still did not find an answer.</p>
  
  <p>I have tried all the possible configuration I found over the web.</p>
  
  <p>My current configuration:</p>
  
  <h3>META-INF\persistence.xml</h3>
  
  <pre><code>&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="appname" transaction-type="JTA"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;jta-data-source&gt;java:/comp/env/jdbc/appname&lt;/jta-data-source&gt;
  
      &lt;class&gt;myorg.mypackage.MyClass&lt;/class&gt;
  
      &lt;properties&gt;
          &lt;property name="hibernate.show_sql" value="true" /&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="create-drop" /&gt;
          &lt;property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JDBCTransactionFactory" /&gt; 
      &lt;/properties&gt;
  
  &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <h3>.openshift\config\context.xml</h3>
  
  <pre><code>&lt;Context&gt;
  &lt;Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
      maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/appname" password="mypass"
      type="javax.sql.DataSource" url="jdbc:mysql://myurl:3306/appname"
      username="myuser" /&gt;
      &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <h3>.openshift\config\server.xml</h3>
  
  <pre><code>&lt;Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="true"&gt;
      &lt;Context docBase="appname" path="/appname" reloadable="true"                    source="org.eclipse.jst.jee.server:appname" /&gt;
  &lt;/Host&gt;
  </code></pre>
  
  <h3>The exception</h3>
  
  <pre><code>javax.persistence.PersistenceException: No Persistence provider for EntityManager named appname
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
      at org.andvicoso.shopand.model.dao.base.GenericDaoJPA.&lt;init&gt;(GenericDaoJPA.java:20)
      at org.andvicoso.shopand.model.dao.ProductDaoJPA.&lt;init&gt;(ProductDaoJPA.java:8)
      at org.andvicoso.shopand.web.ViewHelper.getProductDao(ViewHelper.java:31)
      at org.andvicoso.shopand.web.ViewHelper.getHighlights(ViewHelper.java:37)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
      at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
      at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
      at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:106)
      at org.apache.jsp.index_jsp._jspx_meth_c_005fset_005f6(index_jsp.java:260)
  </code></pre>
  
  <p>Can anyone help me???</p>
  
  <p>Thanks in advance.</p>