[RESOLVIDO][Hibernate][Configuração]

Boa tarde,

Criei um Dynamic Web Project onde pretendo utilizar Hibernate, porém, estou encontrando algum problema de configuração. Baixei os arquivos .zip hibernate-annotations-3.4.0.GA e hibernate-distribution-3.3.2.GA-dist do site www.hibernate.org e depois de descompactar, importei os arquivos .jar existentes na raiz de suas pastas e também os que existiam na pasta lib de cada um. Importei também o c3po e o driver para conexão com o banco de dados Mysql que baixei do site www.mysql.com, o mysql-connector-java-5.1.7.

Não sei o motivo mas ele reclama não ter encontrado uma classe org.slf4j.impl.StaticLoggerBinder

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
	at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
	at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
	at GeraBanco.main(GeraBanco.java:8)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	... 8 more

O arquivo do slf4J é o seguinte

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate= info

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace

E o arquivo hibernate.cfg.xml é o seguinte

[code]

com.mysql.jdbc.Driver jdbc:mysql://localhost/rh root 281002 org.hibernate.dialect.MySQLDialect
	<property name="hibernate.sql_show">true</property>
	<property name="hibernate.sql_format">true</property>
	
	<mapping class="br.com.recrutamento.bean.Telefone"/>

</session-factory>

[/code]

Boa noite,

Bom, aparentemente resolvi o problema baixando conforme uma dica que encontrei aqui no site mesmo o pacote logback-0.9.17.zip no site http://logback.qos.ch/download.html, criei minha classe e rodei uma outra classe para gerar o banco de dados, mas a classe executa e não gera a tabela no banco de dados.

Alguém sabem o que pode ser?

Seguem abaixo, da execução no console e código das minhas duas classes.

18:47:34.134 [main] INFO  o.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
18:47:34.161 [main] INFO  org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
18:47:34.165 [main] INFO  org.hibernate.cfg.Environment - hibernate.properties not found
18:47:34.169 [main] INFO  org.hibernate.cfg.Environment - Bytecode provider name : javassist
18:47:34.174 [main] INFO  org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
18:47:34.250 [main] INFO  o.h.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
18:47:34.252 [main] INFO  org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
18:47:34.253 [main] INFO  org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
18:47:34.319 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
18:47:34.320 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
18:47:34.321 [main] DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
18:47:34.354 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.url=jdbc:mysql://localhost:3306/rh
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.driver_class=com.mysql.jdbc.Driver
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.dialect=org.hibernate.dialect.MySQLDialect
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.username=root
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.connection.password=281002
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.current_session_context_class=thread
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.sql_show=true
18:47:34.355 [main] DEBUG org.hibernate.cfg.Configuration - hibernate.sql_format=true
18:47:34.355 [main] DEBUG o.h.cfg.AnnotationConfiguration - null <- org.dom4j.tree.DefaultAttribute@1386000 [Attribute: name package value "br.com.recrutamento.bean"]
18:47:34.357 [main] INFO  o.h.cfg.AnnotationConfiguration - Mapping package br.com.recrutamento.bean
18:47:34.405 [main] WARN  org.hibernate.cfg.AnnotationBinder - Package not found or wo package-info.java: br.com.recrutamento.bean
18:47:34.405 [main] INFO  org.hibernate.cfg.Configuration - Configured SessionFactory: null
18:47:34.406 [main] DEBUG org.hibernate.cfg.Configuration - properties: {hibernate.connection.password=281002, java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=C:\Program Files\Java\jre6\bin, java.vm.version=11.3-b02, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=BR, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Users\junior\workspace\Recrutamento, hibernate.sql_format=true, java.runtime.version=1.6.0_13-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hibernate.current_session_context_class=thread, java.endorsed.dirs=C:\Program Files\Java\jre6\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\Users\junior\AppData\Local\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows Vista, sun.jnu.encoding=Cp1252, java.library.path=C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Apache Software Foundation\Apache2.2\php526;C:\Program Files\MySQL\MySQL Server 6.0\bin;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Java\jdk1.6.0_12\bin;C:\Program Files\QuickTime\QTSystem\, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=6.0, user.home=C:\Users\junior, user.timezone=America/Sao_Paulo, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.6, hibernate.connection.driver_class=com.mysql.jdbc.Driver, user.name=junior, java.class.path=C:\Users\junior\workspace\Recrutamento\build\classes;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\annotations-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\catalina-ant.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\catalina-ha.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\catalina-tribes.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\catalina.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\el-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\jasper-el.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\jasper-jdt.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\jasper.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\jsp-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\tomcat-coyote.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\tomcat-dbcp.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\tomcat-i18n-es.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\tomcat-i18n-fr.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\tomcat-i18n-ja.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\antlr-2.7.6.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\c3p0-0.9.1.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\cglib-2.2.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\commons-collections-3.1.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\dom4j-1.6.1.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\dom4j.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\ejb3-persistence.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\hibernate-annotations.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\hibernate-commons-annotations.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\hibernate-core.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\hibernate-testing.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\hibernate3.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\javassist-3.9.0.GA.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\jta-1.1.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\logback-access-0.9.17-sources.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\logback-access-0.9.17.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\logback-classic-0.9.17-sources.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\logback-classic-0.9.17.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\logback-core-0.9.17-sources.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\logback-core-0.9.17.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\mysql-connector-java-5.1.7-bin.jar;C:\Users\junior\workspace\Recrutamento\WebContent\WEB-INF\lib\slf4j-api-1.5.8.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.sql_show=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jre6, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost:3306/rh, user.language=pt, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, sharing, java.version=1.6.0_13, java.ext.dirs=C:\Program Files\Java\jre6\lib\ext;C:\Windows\Sun\Java\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre6\lib\resources.jar;C:\Program Files\Java\jre6\lib\rt.jar;C:\Program Files\Java\jre6\lib\sunrsasign.jar;C:\Program Files\Java\jre6\lib\jsse.jar;C:\Program Files\Java\jre6\lib\jce.jar;C:\Program Files\Java\jre6\lib\charsets.jar;C:\Program Files\Java\jre6\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
18:47:34.428 [main] INFO  org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
18:47:34.478 [main] DEBUG o.h.cfg.AnnotationConfiguration - Execute first pass mapping processing
18:47:34.482 [main] DEBUG o.h.cfg.AnnotationConfiguration - Process hbm files
18:47:34.482 [main] DEBUG o.h.cfg.AnnotationConfiguration - Process annotated classes
18:47:34.482 [main] DEBUG o.h.cfg.AnnotationConfiguration - processing fk mappings (*ToOne and JoinedSubclass)
18:47:34.482 [main] DEBUG org.hibernate.cfg.Configuration - processing extends queue
18:47:34.482 [main] DEBUG org.hibernate.cfg.Configuration - processing collection mappings
18:47:34.482 [main] DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
18:47:34.482 [main] DEBUG org.hibernate.cfg.Configuration - processing association property references
18:47:34.482 [main] DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints
18:47:34.483 [main] INFO  o.h.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
18:47:34.485 [main] DEBUG o.h.cfg.AnnotationConfiguration - Execute first pass mapping processing
18:47:34.485 [main] DEBUG o.h.cfg.AnnotationConfiguration - Process hbm files
18:47:34.485 [main] DEBUG o.h.cfg.AnnotationConfiguration - Process annotated classes
18:47:34.485 [main] DEBUG o.h.cfg.AnnotationConfiguration - processing fk mappings (*ToOne and JoinedSubclass)
18:47:34.485 [main] DEBUG org.hibernate.cfg.Configuration - processing extends queue
18:47:34.485 [main] DEBUG org.hibernate.cfg.Configuration - processing collection mappings
18:47:34.486 [main] DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
18:47:34.486 [main] DEBUG org.hibernate.cfg.Configuration - processing association property references
18:47:34.486 [main] DEBUG org.hibernate.cfg.Configuration - processing foreign key constraints
18:47:34.491 [main] INFO  o.h.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
18:47:34.492 [main] DEBUG o.h.tool.hbm2ddl.SchemaExport - import file not found: /import.sql
18:47:34.492 [main] INFO  o.h.tool.hbm2ddl.SchemaExport - exporting generated schema to database
18:47:34.495 [main] INFO  o.h.c.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
18:47:34.495 [main] INFO  o.h.c.DriverManagerConnectionProvider - Hibernate connection pool size: 20
18:47:34.495 [main] INFO  o.h.c.DriverManagerConnectionProvider - autocommit mode: false
18:47:34.502 [main] INFO  o.h.c.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/rh
18:47:34.502 [main] INFO  o.h.c.DriverManagerConnectionProvider - connection properties: {user=root, password=281002}
18:47:34.502 [main] DEBUG o.h.c.DriverManagerConnectionProvider - opening new JDBC connection
18:47:34.965 [main] DEBUG o.h.c.DriverManagerConnectionProvider - created connection to: jdbc:mysql://localhost:3306/rh, Isolation Level: 4
18:47:34.966 [main] INFO  o.h.tool.hbm2ddl.SchemaExport - schema export complete
18:47:34.967 [main] INFO  o.h.c.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:mysql://localhost:3306/rh

Classe para gerar o banco

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class GeraBanco {

	public static void main(String[] args) {

		AnnotationConfiguration configuration = new AnnotationConfiguration();
		configuration.configure();
		SchemaExport se = new SchemaExport(configuration);
		se.create(true, true);

	}

}

Classe Telefone

package br.com.recrutamento.bean;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.annotations.Entity;

@Entity
public class Telefone {

	@Id
	@GeneratedValue
	private Long id_telefone;
	private String ddi;
	private String ddd;
	private String ramal;
	private String numero;

	public Long getId_telefone() {
		return id_telefone;
	}

	public String getDdi() {
		return ddi;
	}

	public String getDdd() {
		return ddd;
	}

	public String getRamal() {
		return ramal;
	}

	public String getNumero() {
		return numero;
	}

	public void setId_telefone(Long id_telefone) {
		this.id_telefone = id_telefone;
	}

	public void setDdi(String ddi) {
		this.ddi = ddi;
	}

	public void setDdd(String ddd) {
		this.ddd = ddd;
	}

	public void setRamal(String ramal) {
		this.ramal = ramal;
	}

	public void setNumero(String numero) {
		this.numero = numero;
	}

}

ok…

Bom pessoal… Resolvido o problema…

Estava no import de uma linha

onde deveria ser

Obrigado pela atenção