2 Replies Latest reply on Apr 6, 2013 2:39 PM by Fabiano Frizzo

    Problem migration from Hibernate 3 to Hibernate 4

    Fabiano Frizzo Newbie

      Hi Folks

       

      I have a problem on migration from Hibernate 3 to Hibernate 4

      I'm use a Jboss 7.1.1

       

      My configuration for Hibernate is.

       

                      ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();  
                         serviceRegistryBuilder
                                    .applySetting(AvailableSettings.DIALECT, "org.hibernate.dialect.PostgreSQLDialect")
                                    .applySetting(AvailableSettings.RELEASE_CONNECTIONS, "after_statement")
                                    .applySetting(AvailableSettings.DRIVER, "org.postgresql.Driver")
                                    .applySetting(AvailableSettings.DATASOURCE, "java:jboss/datasource/optimuslabsDS")
                                    .applySetting(AvailableSettings.TRANSACTION_STRATEGY, "org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory")
                                    .applySetting(AvailableSettings.JTA_PLATFORM, "org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform")
                                    .applySetting(AvailableSettings.FLUSH_BEFORE_COMPLETION, "true")
                                    .applySetting(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, "jta");
      
                          serviceRegistryBuilder
                                    .applySetting(AvailableSettings.SHOW_SQL, hibernateShowSql)
                                    .applySetting(AvailableSettings.FORMAT_SQL, hibernateFormatSql);
        
                                    serviceRegistryBuilder.applySetting(AvailableSettings.DEFAULT_SCHEMA, schemaName);
                                    serviceRegistryBuilder.applySetting("org.hibernate.envers.default_schema",  schemaName + "_aud");
      
                          MetadataSources metadataSources = new MetadataSources( serviceRegistryBuilder.buildServiceRegistry() );
      
                          for ( Class<?> c : this.jpaMappedClasses ){
                                    metadataSources.addAnnotatedClass(c);
                          }
      
                      Metadata metadata = metadataSources.getMetadataBuilder().buildMetadata();
                      SessionFactory sessionFactory = metadata.buildSessionFactory();
      

       

      Well, When I deploy my app I get this erro.

       

       

      14:08:29,442 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/optimus]] (MSC service thread 1-8) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multiSchemaSessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/jboss/jandex/Indexer
                at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:399) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1481) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_10]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_10]
                at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_10]
      Caused by: java.lang.NoClassDefFoundError: org/jboss/jandex/Indexer
                at org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProcessorImpl.prepare(AnnotationMetadataSourceProcessorImpl.java:78) [hibernate-core-4.2.0.Final.jar:4.2.0.Final]
                at org.hibernate.metamodel.source.internal.MetadataImpl.prepare(MetadataImpl.java:177) [hibernate-core-4.2.0.Final.jar:4.2.0.Final]
                at org.hibernate.metamodel.source.internal.MetadataImpl.<init>(MetadataImpl.java:162) [hibernate-core-4.2.0.Final.jar:4.2.0.Final]
                at org.hibernate.metamodel.source.internal.MetadataBuilderImpl.buildMetadata(MetadataBuilderImpl.java:83) [hibernate-core-4.2.0.Final.jar:4.2.0.Final]
                at br.com.optimuslabs.infra.persistence.MultiSchemaSessionFactory.getMetadata(MultiSchemaSessionFactory.java:154) [optimus-java-common-1.0-SNAPSHOT.jar:]
                at br.com.optimuslabs.infra.persistence.MultiSchemaSessionFactory.createSessionFactory(MultiSchemaSessionFactory.java:102) [optimus-java-common-1.0-SNAPSHOT.jar:]
                at br.com.optimuslabs.infra.persistence.MultiSchemaSessionFactory.createGlobalSessionFactory(MultiSchemaSessionFactory.java:88) [optimus-java-common-1.0-SNAPSHOT.jar:]
                at br.com.optimuslabs.infra.persistence.MultiSchemaSessionFactory.create(MultiSchemaSessionFactory.java:60) [optimus-java-common-1.0-SNAPSHOT.jar:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_10]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_10]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_10]
                at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_10]
                at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:344) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:295) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
                ... 22 more
      Caused by: java.lang.ClassNotFoundException: org.jboss.jandex.Indexer from [Module "deployment.optimus.war:main" from Service Module Loader]
                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
                ... 37 more
      
      

       

      I'm not able to discover which real problem.

      Someone have the same problem?

       

      Many Thanks