I have the following config for persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<persistence-unit name="pu" transaction-type="RESOURCE_LOCAL">
<description>Persistent Unit for Entity Classes</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<non-jta-data-source>jdbc/mydb</non-jta-data-source>
<class>com.example.entity.BookEntity</class>
</persistence-unit>
</persistence>
And the following container-managed config for home.xml file (saved under ..\tomcat\conf\catalina\localhost directory):
<Context path="/home" antiJARLocking="true" reloadable="true">
<Resource name="jdbc/mydb" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mydb?autoReconnect=true"
username="user"
password="password"
maxActive="10"
maxIdle="5"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true" />
</Context>
I have tried connecting to the database directly with MySQL Workbench and it works, but I don’t know why I am not able to connect via contextual configuration.
I’m running the app on Tomcat 7 with JSF 2.
Why can’t I connect with the above configurations? If required, I can post codes for the entity, ejb and controller. Please help, been stuck on this for the last three days…
Alas, Tomcat 7 does not support EJB 3 without a lot of mucking about to get it to work. I have moved my project to Glassfish version 3.1.