Could not find any META-INF/persistence.xml file in the classpath [RESOLVIDO]

[color=darkblue]Estou com o seguinte erro, alguém poderia ajudar ? [/color]


16:01:19,046  INFO [Ejb3Configuration.configure:210] Could not find any META-INF/persistence.xml file in the classpath
Exception in thread "main" java.lang.ExceptionInInitializerError
	at br.com.digicon.psecertdb.DaoFactory.<init>(DaoFactory.java:30)
	at br.com.digicon.testes.luciano.TestaCertificadoCriteria.main(TestaCertificadoCriteria.java:21)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named psecertDB
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
	at br.com.digicon.psecertdb.EntityManagerFactoriesUtil.<clinit>(EntityManagerFactoriesUtil.java:59)
	... 2 more

[color=darkblue]Desde já agradeço ! [/color]

Olá!
Crie uma pasta META-INF dentro da pasta /src do seu projeto, lá dentro da META-INF vc cria seu persistence.xml, e dentro desse arquivo vc coloca a configuração:

<?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="default" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  
        <properties>        	
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/meubanco" />
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
            <property name="javax.persistence.jdbc.password" value="123456" />
            <property name="javax.persistence.jdbc.user" value="postgres" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>           
        </properties>
</persistence-unit>
</persistence>

Substitua o usuario, senha e banco de acordo com os seus dados. Eu uso Hibernate e JPA, ai vc coloca de acordo com o que vc está usando, mas o esqueleto do arquivo é esse.
Abraço!

[color=darkblue] Muito obrigado, estava na pasta errada, porém quando criei a pasta gerou o seguinte erro :[/color]

Exception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection
	at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30)
	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
	at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
	at org.hibernate.loader.Loader.doQuery(Loader.java:673)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
	at org.hibernate.loader.Loader.doList(Loader.java:2220)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
	at org.hibernate.loader.Loader.list(Loader.java:2099)
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
	at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
	at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
	at br.com.digicon.psecertdb.dao.CertificadoDao.listAllCriteria(CertificadoDao.java:34)
	at br.com.digicon.testes.luciano.TestaCertificadoCriteria.main(TestaCertificadoCriteria.java:25)

[color=darkblue] Muito obrigado pela ajuda ![/color]

Vc está usando Hibernate + JPA? Se não estiver vc precisa adaptar o persistence.xml de acordo com o que estiver usando. Existem vários exemplos para pegar como referência.
Vc esta usando EJB3?

Ejb3Configuration.configure:210]

Vai ter q adaptar para isso ai. Como eu ainda não usei o EJB3 não vou saber te orientar na configuração, mas vc acha isso pesquisando no fórum ou no google.

[color=darkblue]Obrigado pela ajuda, foi o que você falou ! [/color]

[quote=Guevara]Olá!
Crie uma pasta META-INF dentro da pasta /src do seu projeto, lá dentro da META-INF vc cria seu persistence.xml, e dentro desse arquivo vc coloca a configuração:

<?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="default" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  
        <properties>        	
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/meubanco" />
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
            <property name="javax.persistence.jdbc.password" value="123456" />
            <property name="javax.persistence.jdbc.user" value="postgres" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>           
        </properties>
</persistence-unit>
</persistence>

Substitua o usuario, senha e banco de acordo com os seus dados. Eu uso Hibernate e JPA, ai vc coloca de acordo com o que vc está usando, mas o esqueleto do arquivo é esse.
Abraço![/quote]

Não estava colocando no classpath do projeto, agora corrigi o erro.
Porém apareceu outro erro no console:

[quote]Caused by: javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML [line : -1, column : -1] : cvc-elt.1: Não pode localizar a declaração do elemento ‘persistence’. [/quote]

Uso JPA 2.1,Hibernate 4.3 e Postegresql 9.3
Meu persistence.xml está assim:

<persistence version="2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/persistence" 
xsi:schemalocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/persistence_2_1.xsd">
 
 <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
   
   <provider > org.hibernate.ejb.HibernatePersistence</provider>
   
  <properties>
   <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"></property>
   <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/Automoveis"></property>
   <property name="javax.persistence.jdbc.user" value="postgres"></property>
   <property name="javax.persistence.jdbc.password" value="1234"></property>
   <property name="javax.persistence.jdbc.driver" value="org.postgresql.jdbc.Driver"></property>
   <property name= "hibernate.show_sql" value = "true" />  
   <property name= "hibernate.format_sql" value = "true" />
   
 
   <property name="hibernate.hbm2ddl.auto" value="create"></property>
   
 
  </properties>
 
   
 
 </persistence-unit>
</persistence>

Segue um exemplo funcional do persistence.xml

   &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&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="JSFCrudPU" transaction-type="RESOURCE_LOCAL"&gt;
		&lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;

		&lt;properties&gt;
			&lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
			&lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/JSFCrudDB" /&gt;
			&lt;property name="javax.persistence.jdbc.user" value="postgres" /&gt;
			&lt;property name="javax.persistence.jdbc.password" value="postgres" /&gt;
			&lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
			&lt;property name="hibernate.connection.shutdown" value="true" /&gt;
			&lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
			&lt;property name="hibernate.show_sql" value="false" /&gt;
            &lt;property name="hibernate.format_sql" value="false"/&gt;
		&lt;/properties&gt;
	&lt;/persistence-unit&gt;
&lt;/persistence&gt;

Carmba nada funciona :o
Quando coloco tag :

Da erro :
O destino da instrução de processamento correspondente "[xX][mM][lL]" não é permitido.

Se tiro a tag roda e da o erro:
Não pode localizar a declaração do elemento ‘persistence’.

Minha versão da JPA é 2.1, então no lugar de 2.0 coloco 2.1 ???
É a primeira vez que utilizo e acredito estar deixando alguma coisa passar…

Meu persistense.xml ficou assim:

[code]<?xml version="1.0" encoding="UTF-8"?>

<persistence version="2.1"
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_1.xsd”>

&lt;persistence-unit name="JSFCrudPU" transaction-type="RESOURCE_LOCAL"&gt;  
    &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;  

    &lt;properties&gt;  
        &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;  
        &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/Automoveis" /&gt;  
        &lt;property name="javax.persistence.jdbc.user" value="postgres" /&gt;  
        &lt;property name="javax.persistence.jdbc.password" value="1234" /&gt;  
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;             
        &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;  
        &lt;property name="hibernate.show_sql" value="true" /&gt;  
        &lt;property name="hibernate.format_sql" value="true"/&gt;  
    &lt;/properties&gt;  
&lt;/persistence-unit&gt;  

</persistence>
[/code]

[quote=Metaleiro]Segue um exemplo funcional do persistence.xml

[code]
<?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”>

&lt;persistence-unit name="JSFCrudPU" transaction-type="RESOURCE_LOCAL"&gt;
	&lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;

	&lt;properties&gt;
		&lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
		&lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/JSFCrudDB" /&gt;
		&lt;property name="javax.persistence.jdbc.user" value="postgres" /&gt;
		&lt;property name="javax.persistence.jdbc.password" value="postgres" /&gt;
		&lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
		&lt;property name="hibernate.connection.shutdown" value="true" /&gt;
		&lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
		&lt;property name="hibernate.show_sql" value="false" /&gt;
        &lt;property name="hibernate.format_sql" value="false"/&gt;
	&lt;/properties&gt;
&lt;/persistence-unit&gt;

</persistence>
[/code][/quote]

Eu uso exatamente dessa maneira com o :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

Você tem certeza que está no diretório correto ?

Dentro do META-INF ?

Você deixou o name com o nome do projeto que mandei, tente mudar também:

&lt;persistence-unit name="JSFCrudPU" transaction-type="RESOURCE_LOCAL"&gt; 
&lt;persistence-unit name="default" transaction-type="RESOURCE_LOCAL"&gt; 

Colei aqui antes de editar mas arrumei sim o name…
Tem algo mal no meu xml, mas não consigo perceber…

Exatamente assim como postei abaixo da o erro: The processing instruction must begin with the name of the target.
E no console : A instrução de processamento deve começar com o nome do destino.

[code]<?Xml version=“1.0” encoding =“UTF-8” >

<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">  
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  

    <properties>  
        <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />  
        <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/Automoveis" />  
        <property name="javax.persistence.jdbc.user" value="postgres" />  
        <property name="javax.persistence.jdbc.password" value="1234" />  
        <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />             
        <property name="hibernate.hbm2ddl.auto" value="update" />  
        <property name="hibernate.show_sql" value="true" />  
        <property name="hibernate.format_sql" value="true"/>  
    </properties>  
</persistence-unit>  
[/code]

Ahhhhhhhhhhhhh deu certo!
Tirei a tag xml version…

Mas uma dúvida ficou: se a versão da JPA é 2.1 porque só funcionou com 2.0 no persistente.xml???

Obrigada pessoal!!!
Ficou assim: :smiley:

[code]

<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">  
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  

    <properties>  
        <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />  
        <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/Automoveis" />  
        <property name="javax.persistence.jdbc.user" value="postgres" />  
        <property name="javax.persistence.jdbc.password" value="1234" />  
        <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />             
        <property name="hibernate.hbm2ddl.auto" value="update" />  
        <property name="hibernate.show_sql" value="true" />  
        <property name="hibernate.format_sql" value="true"/>  
    </properties>  
</persistence-unit>  
[/code]