Erro Hibernate [RESOLVIDO]

Sou iniciante em java, estava tentando usar o hibernate para persistir os dados
está aparecendo o seguinte erro.

run: 94 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final 110 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.0.Final 110 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 110 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 110 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 172 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: hibernate/hibernate.cfg.xml 172 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: hibernate/hibernate.cfg.xml 500 [main] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! org.hibernate.HibernateException: Could not parse configuration: hibernate/hibernate.cfg.xml at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2216) at org.hibernate.cfg.Configuration.configure(Configuration.java:2128) at model.Teste.main(Teste.java:23) Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2208) ... 2 more

meu arquivo de configuracao é

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

oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@127.0.0.1:1521:xe tecnicos tecnicos org.hibernate.dialect.Oracle10gDialect [/code]

e o meu de mapeamento é

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

[/code]

por favor me ajudem.

Aparentemente seu problema esta no Hibernate Util…
posta ele pra nos verificarmos!

esse banco esta acessível???

Sim. É um Oracle 10G Express Edition que está instalado na minha maquina local.

[code]public class ConnectionFactory {
public static void main(String[] args) {
new ConnectionFactory().getConnection();
}

public void getConnection() {

	try {

		Class.forName("oracle.jdbc.driver.OracleDriver");

		DriverManager.getConnection(
				"jdbc:oracle:thin:@127.0.0.1:1521:xe", "tecnicos","tecnicos");

		System.out.println("Conectou!");
	} catch (SQLException e) {
		e.printStackTrace();

	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	}
}

}[/code]

se vc usar essa classe o q acontece???

o serviço do banco esta iniciado? o listener tb??

att,

Ao executar a classe ConnectionFactory
conecta normalmente.

[quote]run:
Conectou!
CONSTRUÍDO COM SUCESSO (tempo total: 5 segundos)
[/quote]

vê se ajuda:

http://www.guj.com.br/java/117522-erro-hibernate-resolvido
http://www.coderanch.com/t/216716/ORM/java/Could-not-parse-hibernate-cfg
https://forum.hibernate.org/viewtopic.php?p=2372397

e posta ai o seu Teste.java

att,

ta ai

[code]public class Teste {
public static void main(String[] args){
try{
SessionFactory factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
Empresa p = new Empresa();
p.setEmp_id(1);
p.setEmp_fili_codi(2);
p.setEmp_nome(“kldklaskdlas”);
p.setEmp_email(“kd@dajdajksd”);

        session.save(p);
        tx.commit();
        session.close();

    }catch(HibernateException e1){
        e1.printStackTrace();
    }

}

}
[/code]

Eu mudei meu hibernate.cfg.xml para

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

oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@127.0.0.1:1521:xe tecnicos tecnicos org.hibernate.dialect.Oracle10gDialect [/code]

e apresentou os seguintes erros.

[quote]run:
94 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
109 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.0.Final
109 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
125 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
125 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
187 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
187 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
266 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : hibernate/empresa.hbm.xml
297 [main] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
328 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
Exception in thread “main” java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96)
at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at model.Teste.main(Teste.java:22)
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
… 5 more
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)
[/quote]

A versao do hibernate que eu estou usando é a hibernate-distribution-3.6.0.Final-dist

para essa sua 2° versão do cfg:

http://www.coderanch.com/t/513512/ORM/java/Error-java-lang-NoClassDefFoundError-javax
https://forum.hibernate.org/viewtopic.php?f=1&t=1007502
http://technicalrecyclebin.wordpress.com/2010/11/29/exception-in-thread-main-java-lang-noclassdeffounderror-javaxpersistenceentitylisteners/

att,

Obrigado

Estava faltando o jar hibernate-jpa-2.0-api-1.0.0.Final.jar

show de bola!

se estiver td ok não esqueça do [Resolvido]

att,

Vlw, era o mesmo problema que estava enfrentando, faltava o Jpa