3 Replies Latest reply on Feb 6, 2012 4:08 AM by pushpak1981

    Problem Jboss7.1 Hibernate 3 module

    pushpak1981 Novice

      Hi,

       

      We have created a hibernate3 module for Jboss 7 as mentioned in the Jboss7 Guide and used hibernate 3 module for JPA. Database operations works fine. But when we try to create a EntityManagerFactory using the API it throws the following error.

       

      API: javax.persistence.Persistence.createEntityManagerFactory("")

       

      16:48:58,284 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/gwt-console-server].[Resteasy]] (
              at org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.3.GA.jar:]
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.3.Final.jar:]
              at org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59) [classes:]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.3.Final.jar:]
              at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Beta1b.jar:]
              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.Beta1b.jar:]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.3.Final.jar:]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.3.Final.jar:]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.3.Final.jar:]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.3.Final.jar:]
              at java.lang.Thread.run(Thread.java:619) [:1.6.0_03]
      Caused by: java.lang.RuntimeException: Could not initialize stateful knowledge session: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityMa
              at org.jbpm.integration.console.CommandDelegate.newStatefulKnowledgeSession(CommandDelegate.java:244) [jbpm-gwt-core-5.2.0.Final.jar:]
              at org.jbpm.integration.console.CommandDelegate.getSession(CommandDelegate.java:252) [jbpm-gwt-core-5.2.0.Final.jar:]
              at org.jbpm.integration.console.CommandDelegate.<init>(CommandDelegate.java:92) [jbpm-gwt-core-5.2.0.Final.jar:]
              at org.jbpm.integration.console.ProcessManagement.<init>(ProcessManagement.java:35) [jbpm-gwt-core-5.2.0.Final.jar:]
              at org.jbpm.integration.console.ManagementFactory.createProcessManagement(ManagementFactory.java:22) [jbpm-gwt-core-5.2.0.Final.jar:]
              at org.jbpm.integration.console.ManagementFactory.createProcessManagement(ManagementFactory.java:19) [jbpm-gwt-core-5.2.0.Final.jar:]
              at org.jboss.bpm.console.server.ProcessMgmtFacade.getProcessManagement(ProcessMgmtFacade.java:86) [classes:]
              at org.jboss.bpm.console.server.ProcessMgmtFacade.getDefinitionsJSON(ProcessMgmtFacade.java:122) [classes:]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_03]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_03]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_03]
              at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_03]
              at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209) [resteasy-jaxrs-2.2.3.GA.jar:]
              at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519) [resteasy-jaxrs-2.2.3.GA.jar:]
              ... 24 more
      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) [hibernate3.jar:]
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) [hibernate3.jar:]
              at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56) [hibernate3.jar:]
              at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:]
              at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:]
              at org.jbpm.integration.console.CommandDelegate.newStatefulKnowledgeSession(CommandDelegate.java:154) [jbpm-gwt-core-5.2.0.Final.jar:]
              ... 40 more
      Caused by: org.hibernate.HibernateException: Could not instantiate dialect class
              at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:82)
              at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
              at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:142)
              at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:165)
              at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:139)
              at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate3.jar:]
              at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2259) [hibernate3.jar:]
              at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2255) [hibernate3.jar:]
              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724) [hibernate3.jar:]
              at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76) [hibernate3.jar:]
              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) [hibernate3.jar:]
              ... 45 more
      Caused by: java.lang.ClassCastException: org.hibernate.dialect.Oracle10gDialect cannot be cast to org.hibernate.dialect.Dialect
              at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
              ... 56 more
      

       

      Can it be a case where in jars are loaded from different hibernate modules. We verified there are no hibernate jars in our application and no jboss-deployment-structure.xml file.

       

      We have both hiberate main and hibernate 3 modules and JPA subsystem is also enabled in standalone-full.xml.

       

      Also following are the properties we configured in persistence.xml to use hibernate 3 JPA.

       

      <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>          
            <property name="hibernate.max_fetch_depth" value="3"/>
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.show_sql" value="false" />        
            <property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
            <property name="jboss.entity.manager.factory.jndi.name" value="java:/HumanTaskFactory"/>
          </properties>