Hibernate 3.6.0

Olá pessoal

Estou tendo a seguinte mensagem de erro:

2011-02-01 13:44:43.676:WARN::failed vraptor: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactoryCreator': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider 2011-02-01 13:44:43.676:WARN::Failed startup of context org.mortbay.jetty.webapp.WebAppContext@6be26bd2{/rental,/Applications/jetty-6.1.22/webapps/rental.war} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactoryCreator': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.start(SpringBasedContainer.java:68) at br.com.caelum.vraptor.ioc.spring.SpringProvider.start(SpringProvider.java:82) at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:110) at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:103) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.deployer.ContextDeployer.deploy(ContextDeployer.java:268) at org.mortbay.jetty.deployer.ContextDeployer.redeploy(ContextDeployer.java:287) at org.mortbay.jetty.deployer.ContextDeployer.access$100(ContextDeployer.java:67) at org.mortbay.jetty.deployer.ContextDeployer$ScannerListener.fileChanged(ContextDeployer.java:99) at org.mortbay.util.Scanner.reportChange(Scanner.java:464) at org.mortbay.util.Scanner.reportDifferences(Scanner.java:330) at org.mortbay.util.Scanner.scan(Scanner.java:280) at org.mortbay.util.Scanner$1.run(Scanner.java:232) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) 2011-02-01 13:44:43.678:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactoryCreator': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider 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 java.lang.ClassLoader.loadClass(ClassLoader.java:248) at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:401) at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363) at br.com.caelum.vraptor.util.hibernate.SessionFactoryCreator.create(SessionFactoryCreator.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.start(SpringBasedContainer.java:68) at br.com.caelum.vraptor.ioc.spring.SpringProvider.start(SpringProvider.java:82) at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:110) at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:103) at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662) at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at org.mortbay.jetty.deployer.ContextDeployer.deploy(ContextDeployer.java:268) at org.mortbay.jetty.deployer.ContextDeployer.redeploy(ContextDeployer.java:287) at org.mortbay.jetty.deployer.ContextDeployer.access$100(ContextDeployer.java:67) at org.mortbay.jetty.deployer.ContextDeployer$ScannerListener.fileChanged(ContextDeployer.java:99) at org.mortbay.util.Scanner.reportChange(Scanner.java:464) at org.mortbay.util.Scanner.reportDifferences(Scanner.java:330) at org.mortbay.util.Scanner.scan(Scanner.java:280) at org.mortbay.util.Scanner$1.run(Scanner.java:232) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462)

Eu só consegui resolver incluindo o jar:

hibernate-commons-annotations-3.2.0.Final.jar

Que é um jar da versão antiga(?) do hibernate onde tem essa classe. Obs.: atualizei o spring para a versão 3.0.5

Tem alguma outra forma de resolver o problema?

Obrigado.

o hibernate 3.6.0 deveria ser suficiente, não precisa do annotations… vc não está com algum jar antigo do hibernate fora ele?

Tenta colocar buildSessionFactory() no lugar de sessionFactoryCreator

Olá,

Eu tive problema semelhante e passou a funcionar após atualizar o Spring para o 3.0.5.

Deivid

Estou com o mesmo erro.

Abaixo, o código de main e a mensagem de erro. Estou usando o eclipse.

[code]import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.*;
import org.hibernate.cfg.Configuration;

import modelos.Produto;

@SuppressWarnings(“deprecation”)
public class Main {

/**
 * @param args
 */
public static void main(String[] args) {
	// TODO Auto-generated method stub
	SessionFactory sf = (SessionFactory) new AnnotationConfiguration()
	.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect")
	.setProperty("hibernate.connection.driver_class", "org.postgresql.driver")
	.setProperty("hibernate.connection.url","jdbc:postgrsql://localhost:5432/Estoque")
	.setProperty("hibernate.connection.username","postgres")
	.setProperty("hibernate.connection.password", "senha_aqui")
	.setProperty("hibernate.show_sql", "true")
	.setProperty("hibernate.format_sql", "true")
	.setProperty("hibernate.c3p0.acquire_increment", "1")
	.setProperty("hibernate.c3p0.idle_test_period", "100")
	.setProperty("hibernate.c3p0.max_size", "10")
	.setProperty("hibernate.c3p0.max_statements", "0")
	.setProperty("hibernate.c3p0.min_size", "5")
	.setProperty("hibernate.c3p0.timeut","100")
	.addAnnotatedClass(modelos.Produto.class)
	.buildSessionFactory();
	
	Session session = sf.openSession();
	
	session.beginTransaction();
	
	Produto p = (Produto) session.get(Produto.class, 1);
	
	//fechar transações
	session.getTransaction();
	session.close();
	sf.close();
	

}

}[/code]

[color=red]Exception in thread “main” java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
at Main.main(Main.java:17)
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider
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)
… 1 more[/color]

oi amigo como vc consegui resolver o erro “Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider” que vc postou por ultimo?

Olá amigos,

Aqui na minha maquina eu substituir o char:

		<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>3.3.0.ga</version>
        </dependency>

Por:

		<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>3.2.0.Final</version>
        </dependency>

E rodou legal.

Abraços.