I'm getting this error:
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named EmployeeDb at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at staffManagement.test.TestHarness.main(TestHarness.java:14)
But I just can't understand why - I did the identical thing on my home pc and had no issues. Here is my code for my test file:
public class TestHarness {
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("EmpDb");
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
Employee employee1 = new Employee("Brad", "Pitt", "Actor", 10000);
em.persist(employee1);
tx.commit();
em.close();
}
}
and my persistence.xml file:
<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"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="EmpDb" transaction-type="RESOURCE_LOCAL">
<class>staffManagement.domain.Employee</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/DbName" />
<property name="javax.persistence.jdbc.user" value="APP" />
<property name="javax.persistence.jdbc.password" value="APP" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
Please help me! I'm ripping my hair out. I'm using Eclipse and Derby db. I have the persistence.xml file in the meta-inf folder.