Problemas com (hibernate.cfg.xml)

Olá,
Pessoal eu sei que existe milhares de tópicos para esse problema, porem nenhum consegui resolver.
Vou listar todas as minhas configurações:

CLASS-PATH:

[b]C:\Documents and Settings\tavarebr\My
Documents\NetBeans\TesteH\src\HibTest\hibernate.cfg.xml;[/b]
C:\hibernate-3.0\hibernate3.jar

Arquivo hibernate.cfg.xml:

<!DOCTYPE hibernate-configuration PUBLIC
	"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
	<session-factory>
	
		<property 
			name="hibernate.dialect">
			org.hibernate.dialect.MySQLDialect
		</property>
		<property 
			name="hibernate.connection.driver_class">
			com.mysql.jdbc.Driver
		</property>
		<property 
			name="hibernate.connection.url">
			jdbc:mysql://localhost/hibernate?autoReconnect=true
		</property>
		<property 
			name="hibernate.connection.username">
			root
		</property>
		<property 
			name="hibernate.connection.password">
		</property>		
		
		<!-- Condiguração do c3p0 -->
		
		<property name="hibernate.c3p0.max_size">10</property>
		<property name="hibernate.c3p0.min_size">2</property>
		<property name="hibernate.c3p0.timeout">5000</property>		
		<property name="hibernate.c3p0.max_statements">10</property>
		<property name="hibernate.c3p0.idle_test_period">3000</property>
		<property name="hibernate.c3p0.acquire_increment">2</property>			

		<!-- Configurações de debug -->

		<property name="show_sql">true</property>
        <property name="use_outer_join">true</property>	
        <property name="hibernate.generate_statistics">true</property>
        <property name="hibernate.use_sql_comments">true</property>
        	
		<mapping resource="Curso.hbm.xml"/>
		<mapping resource="Disciplina.hbm.xml"/>
		<mapping resource="Turma.hbm.xml"/>			
		<mapping resource="Pessoa.hbm.xml"/>	
		<mapping resource="Aluno.hbm.xml"/>		
		<mapping resource="Professor.hbm.xml"/>		
		<mapping resource="Endereco.hbm.xml"/>
			
	</session-factory>
</hibernate-configuration>

ERRO:


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.HibernateException: /hibernate.cfg.xml not found
        at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1087)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1111)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
        at HibTest.HibernateUtility.<clinit>(HibernateUtility.java:28)
        at HibTest.Teste.main(Teste.java:10)
Exception in thread "main" java.lang.NullPointerException
        at HibTest.HibernateUtility.getSession(HibernateUtility.java:39)
        at HibTest.Teste.main(Teste.java:10)
Java Result: 1

Já configurei os JAR’s no classpath do NetBeans.

Não sei mais o que fazer…

Alguém pode me ajudar?:???

O hibernate não está achando seu arquivo de configuração.
Posta o código da sua classe que inicializa o Hibernate.

[]'s

Danilo Carlos Avante
danilo.avante@uol.com.br

E ai, beleza?Cara voce tem que criar um arquivo chamado log4j.properties na pasta src, contendo este script:

mrsmylle eu já tinha esse arquivo log4j e está igualzinho ao seu.

Avante, ai vai o código que inicializa o Hibernate…

vlw

package HibTest;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtility {

    private static SessionFactory factory;
        
    static {
    	//Bloco estático que inicializa o Hibernate
    	try {
    	
        factory = new Configuration().configure().buildSessionFactory();
    	
    	} catch (Exception e) {
    		
    		e.printStackTrace();
    		factory = null;
    	}
    }
    
    public static Session getSession() {
        //Retorna a sessão aberta
    	return factory.openSession();
        
    }
    
}

Coloque o hibernate.cfg.xml dentro da pasta “src”.

Não funcionou…

Olha minha estrutura:

My Documents
±—NetBeans
±-------TesteH
±-----------src
±--------------hibernate.cfg.xml
±--------------HibTest
±------------------(…Resto dos Arquivos…)

OBS: O meu arquivo hibernate estava dentro da pasta /HibTest, e mesmo assim não funcionou

Você consertou o classpath pra colocar ele também?

Se você não disser qual o caminho (como está lá na classe HibernateUtility) ele vai procurar o arquivo hibernate.cfg.xml dentro da pasta raiz do classpath.

Cara meu classpath ficou:


C:\Documents and Settings\tavarebr\My
 Documents\NetBeans\TesteH\src\hibernate.cfg.xml;
 C:\hibernate-3.0\hibernate3.jar

E deu o mesmo erro… :frowning: