Gente, estou tentando persistir dados usando hibernate e arquivo de configuração properties, porém mesmo o arquivo properties estando presente e configurado fico recebendo um erro referente a falta do arquivo hibernate.cfg.xml. Não entendo porque ele fica pedindo o arquivo hibernate.cfg.xml se eu já tenho o arquivo de configuração em formato properties.
1 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.5.2-Final
24 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.2-Final
28 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.format_sql=true, hibernate.connection.username=postgres, hibernate.hbm2ddl.auto=create;, hibernate.connection.url=jdbc:postgresql://localhost:5432/Jcounter, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****}
34 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
37 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
156 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
164 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
164 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
at br.com.jcounter.extras.HibernateUtil.<clinit>(HibernateUtil.java:28)
at br.com.jcounter.extras.Dao.<init>(Dao.java:23)
at testeGravacao.main(testeGravacao.java:66)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1497)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1519)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1194)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:107)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1188)
at br.com.jcounter.extras.HibernateUtil.<clinit>(HibernateUtil.java:24)
... 2 more
Java Result: 1
Aqui o meu arquivo properties.
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql://localhost:5432/Jcounter
hibernate.connection.username = postgres
hibernate.connection.password = postgres
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql = true
hibernate.format_sql = true
hibernate.hbm2ddl.auto=create;