Hibernate, alguém me ajude

6 respostas
Fabaum

Estou desenvolvendo um projeto usanto hibernate pela primeira vez (Eclipse+hibernate+mysql), há fiz uma boa parte do trabalho mas ao tentar executar meu sistema dá o seguinte ERRO:

Initializing c3p0 pool… com.mchange.v2.c3p0.PoolBackedDataSource@7f4ec [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@c9d92c [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 3000, initialPoolSize -> 8, maxIdleTime -> 5000, maxPoolSize -> 15, maxStatements -> 10, maxStatementsPerConnection -> 0, minPoolSize -> 8, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1a082e2 [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://localhost:3306/vacinacao, properties -> {user=******, password=******} ] , preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> 7f4ec ]

Exception in thread “AWT-EventQueue-0” java.lang.ExceptionInInitializerError

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException>null

at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)

at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)

at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)

at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108 )

at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)

at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:321)

 12 more

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)

at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)

 17 more

Caused by: java.lang.IllegalAccessError: class org.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory$$KeyFactoryByCGLIB$$f37b4e4d cannot access its superinterface org.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

 23 more

PELA POUCA EXPERIÊNCIA COM HIBERNATE PARECE QUE ELE COMEÇA A CONEXÃO COM O MYSQL MAS DÁ ESSE ERRO DEPOIS…

SE ALGUÉM PUDER ME AJUDAR

6 Respostas

Fabaum

COMO DISSE SOU INICIANTE E O ECLIPSE CRIOU DOIS cfg.xml NO MEU PROJETO:

1 QUE É ESTE ABAIXO NO PACOTE src DO MEU PROJETO E OUTRO NA RAIZ DO PROJETO QUE O CÓDIGO ESTÁ ABAIXO DESTE…

<?xml version="1.0" encoding="utf-8"?> false com.mysql.jdbc.Driver masterkey jdbc:mysql://localhost:3306/vacinacao sysdba vacinacao vacinacao org.hibernate.dialect.MySQLInnoDBDialect

*********** SEGUNDO ARQUIVO***********************

<?xml version="1.0" encoding="UTF-8"?> com.mysql.jdbc.Driver masterkey jdbc:mysql://localhost:3306/vacinacao sysdba vacinacao vacinacao org.hibernate.dialect.MySQLInnoDBDialect
A

Cara seguinte somente um arquivo, ou cfg ou config, deve ter na sua aplicação, e dentro deste arquivo que vc ira comunicar com o banco de dados, pois dentro dele tera todas as hbm.xml de seus beans, da uma verificada no site que pode te ajudar melhor blz

http://www.hibernate.org/

abrçs

Fabaum

Alessandro_Alves:
Cara seguinte somente um arquivo, ou cfg ou config, deve ter na sua aplicação, e dentro deste arquivo que vc ira comunicar com o banco de dados, pois dentro dele tera todas as hbm.xml de seus beans, da uma verificada no site que pode te ajudar melhor blz

http://www.hibernate.org/

abrçs

Ok, vou dar mais outra olhada na documentação do hibernate. E Muito obrigado pela dica, vou tentar dar uma olhada nos meus cfg.xml

abraço

SE MAIS ALGUÉM PUDER DAR ALGUMA DICA FICARIA GRATO

S

olha posso dizer sim,

digo pra você deixar somente o hbm.xml,

soh uma pergunta vc disse que o eclipse gerou os arquivos pra vc !!

vc está usando algum plugin ??

> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> 7f4ec ]

como vc está criando sua session ?? post o codigo ai pra gente dar uma olhada !!

:lol:

Fabaum

soudaniel_01:
olha posso dizer sim,

digo pra você deixar somente o hbm.xml,

soh uma pergunta vc disse que o eclipse gerou os arquivos pra vc !!

vc está usando algum plugin ??

> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> 7f4ec ]

como vc está criando sua session ?? post o codigo ai pra gente dar uma olhada !!

:lol:

ESTOU USANDO O PLUGIN DO HIBERNATE PARA ECLIPSE.

TÁ AÍ O CÓDIGO DA SESSION.

import java.io.File;

import org.hibernate.HibernateException;

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;
public class SaudeFactory {

public static SessionFactory factory = null;

public static Configuration config   = null;
public static void inicializaFactory(){
    try {
        config = new Configuration();
        config.configure(new File("src/hibernate.cfg.xml"));
        
        /** Configuração para o C3PO */
        config.setProperty("hibernate.c3p0.max_size",         "15");
        config.setProperty("hibernate.c3p0.min_size",         "8");
        config.setProperty("hibernate.c3p0.timeout",          "5000");
        config.setProperty("hibernate.c3p0.max_statements",   "10");
        config.setProperty("hibernate.c3p0.idle_test_period", "3000");
        config.setProperty("hibernate.c3p0.acquire_increment","2");
        
        /** Configuração do Debug */
        config.setProperty("show_sql",                      "false");
        config.setProperty("hibernate.generate_statistics", "false");
        config.setProperty("hibernate.use_sql_comments",    "false");
        
        factory = config.buildSessionFactory();
    } catch (HibernateException hex) {
        factory = null;
        System.exit(0);
        
    }
    
}

public static Session getSession() {
    if (SaudeFactory.factory == null){
        inicializaFactory();
    }
    return factory.openSession();
}

}

everson_z

Como esta seu hibernate.config.xml ou hibernate.cfg.xml ?

Criado 31 de agosto de 2007
Ultima resposta 31 de ago. de 2007
Respostas 6
Participantes 4