0

I had this web project setup on Glassfish, but I decided to move to Tomcat since I was having some problems.

But now my persistence class is throwing the following error

Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named JetCarBd

I've tried placing the persistence.xml on different folders, but it haven't worked.

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">
<persistence-unit name="JetCarBd" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>br.com.jetcar.entity.Cliente</class>
<class>br.com.jetcar.entity.Endereco</class>
<class>br.com.jetcar.entity.Veiculo</class>
<class>br.com.jetcar.entity.Aluguel</class>
<class>br.com.jetcar.entity.Venda</class>
<class>br.com.jetcar.entity.Interesse</class>
<class>br.com.jetcar.entity.Funcionario</class>
<class>br.com.jetcar.entity.ItensAluguel</class>
<class>br.com.jetcar.entity.AcessorioAluguel</class>
<class>br.com.jetcar.entity.TestDrive</class>
<class>br.com.jetcar.entity.AcessorioVeiculo</class>
<class>br.com.jetcar.entity.Acessorio</class>
<class>br.com.jetcar.entity.Oficina</class>
<class>br.com.jetcar.entity.Manutencao</class>
<class>br.com.jetcar.entity.Reserva</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
  <property name="javax.persistence.jdbc.url"  value="jdbc:postgresql://localhost:5432/jetcar"/>
  <property name="javax.persistence.jdbc.password" value="postgres"/>
  <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
  <property name="javax.persistence.jdbc.user" value="postgres"/>
 </properties>
  </persistence-unit>
</persistence>

ConnectionUtil.java

package br.com.jetcar.connection;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * @author Jorge Oliveira
 */
public class ConnectUtil {

private  final EntityManagerFactory emf;

public ConnectUtil(){
    emf = Persistence.createEntityManagerFactory("JetCarBd");
}

public EntityManager getEntityManager() {
    return emf.createEntityManager();
}


}

My persistence.xml is located under src/META-INF

1 Answer 1

1

You can check for couple of things here:

  1. After you have deployed your application ensure that persistence.xml is available under

WEB-INF/classes/META-INF folder

  1. Your provider (eclipse jpa) jars are in the classpath, for Eclipse Env in build path, and also check if that is available in the deployed application.
8
  • I'm sorry, but where is located the folder that contains the deployed project by eclipse? In the glassfish it was right under the server folder. Apr 23, 2012 at 18:35
  • In case you are deploying from eclipse then default folder is your <Your_Workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps. Alternatively you can double click on your sever and then check your deploy path(It will be visible in eclipse editor under Server Location
    – mprabhat
    Apr 23, 2012 at 18:39
  • Alright, so the persistence.xml is under WEB-INF/classes/META-INF folder.I've the EclipseLink library as a user library on my project and because of that I get this warning on the Markers tab Description Resource Path Location Type Classpath entry org.eclipse.jdt.USER_LIBRARY/EclipseLink 2.3.2 - Indigo will not be exported or published. Runtime ClassNotFoundExceptions may result. JetCar P/JetCar Classpath Dependency Validator Message. But I still get the library on the deploy. Apr 23, 2012 at 18:46
  • Add this library in your WEB-INF/lib folder and redeploy, ensure all other dependencies are copied as well in WEB-INF/lib folder
    – mprabhat
    Apr 23, 2012 at 18:47
  • 1
    After adding those libraries to the lib folder a bunch of errors showed up all of them referencing annotations like Abr 23, 2012 3:56:09 PM org.apache.catalina.startup.ContextConfig checkHandlesTypes WARNING: Unable to load class [org.apache.xml.resolver.Catalog] to check against the @HandlesTypes annotation of one or more ServletContentInitializers. java.lang.ClassNotFoundException: org.apache.xml.resolver.Catalog Apr 23, 2012 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.