8 Replies Latest reply on Mar 22, 2012 3:12 PM by thinksteep

    Upgrade to Jboss7.1 Hibernate issue

    thinksteep

      Hi All,

       

      I am getting following exception while upgrading to jboss7.1. It is working fine in jboss4.2.3. Could you please provide some pointers to overcome this? I understood that jboss7.1 JNDI lookup mechanism changed, but don't have any clue on how to do this configuration for UserTransacation with 7.1.

       

      Attached server.log

       

      And here is hibernate.cfg.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

      <hibernate-configuration>

        <session-factory>

       

          <property name="connection.datasource">java:/datasource</property>

          <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

          <property name="hibernate.transaction.manager_lookup_class">

                  org.hibernate.transaction.JBossTransactionManagerLookup

              </property>

          <property name="hibernate.session_factory_name">java:hibernate/SessionFactory</property>

          <property name="hibernate.jdbc.batch_size">50</property>

       

          <property name="current_session_context_class">thread</property>

          <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

          <property name="hibernate.connection.pool_size">0</property>

          <property name="hibernate.max_fetch_depth">5</property>

          <property name="show_sql">false</property>

          <property name="format_sql">false</property>

          <property name="cache.use_query_cache">false</property>

          <property name="cache.use_minimal_puts">false</property>

      ..................

      ...................

        </session-factory>

      </hibernate-configuration>

       

      Thank you for your time and help.

        • 1. Re: Upgrade to Jboss7.1 Hibernate issue
          thinksteep

          Hi All,

           

          Please some one shed light on this? I tried couple of alternatives and nothing worked.

           

          Thanks for your time and help.

          • 2. Re: Upgrade to Jboss7.1 Hibernate issue
            smarlow

            try removing these properties:

             

            <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
            
            <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup
               </property>
            

             

            • 3. Re: Upgrade to Jboss7.1 Hibernate issue
              thinksteep

              Hi Scott,

               

              Thanks for your reply!

               

              I am about to send a private message to you and saw your reply. I tried as you suggested and got this exception: I am not sure what configuration I am missing. Your help would be really appreciated.

               

              We are using [hibernate3.jar:3.2.6] as shows in exception stack.

               

               

              15:14:07,740 WARN  [org.hibernate.impl.SessionFactoryObjectFactory] (MSC service thread 1-3) Could not bind factory to JNDI: javax.naming.NameNotFoundException: java:hibernate

                  at org.jboss.as.naming.InitialContext.createSubcontext(InitialContext.java:237)

                  at org.jboss.as.naming.NamingContext.createSubcontext(NamingContext.java:345)

                  at javax.naming.InitialContext.createSubcontext(InitialContext.java:464) [rt.jar:1.6.0_16]

                  at org.hibernate.util.NamingHelper.bind(NamingHelper.java:69) [hibernate3.jar:3.2.6.ga]

                  at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90) [hibernate3.jar:3.2.6.ga]

                  at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306) [hibernate3.jar:3.2.6.ga]

                  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300) [hibernate3.jar:3.2.6.ga]

                  at com.name.yyy.persistence.HibernateUtil.<clinit>(HibernateUtil.java:45) [yyybusiness.jar:2.1.0 (build: SVNTag=11504)]

                  at com.name.yyy.beans.admin.config.ConfigBean.getEnabled(ConfigBean.java:260) [yyybusiness.jar:2.1.0 (build: SVNTag=11504)]

                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_16]

                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_16]

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_16]

                  at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_16]

                  at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropogatingInterceptor.processInvocation(EJBRemoteTransactionPropogatingInterceptor.java:80) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                  at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]

                  at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:173) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:92) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:175) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.2.Final.jar:1.0.2.Final]

                  at $Proxy52.getEnabled(Unknown Source)    at com.name.yyy.delegates.admin.ConfigDelegate.getEnabled(ConfigDelegate.java:56) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                  at com.name.yyy.delegates.schedule.AlertAutoDeleteSchedule.startAlertAutoDeleteSchedule(AlertAutoDeleteSchedule.java:41) [delegator.jar:2.1.0 (build: SVNTag=11504)]

                  at com.name.yyy.webapp.servlets.InitServlet.init(InitServlet.java:183)

                  at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                  at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)

                  at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)

                  at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655)

                  at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873)

                  at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)

                  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$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_16]

                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_16]

                  at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_16]

               

              15:14:07,884 INFO  [org.quartz.simpl.SimpleThreadPool] (MSC service thread 1-3) Job execution threads will use class loader of thread: MSC service thread 1-3

              15:14:07,899 INFO  [org.quartz.core.SchedulerSignalerImpl] (MSC service thread 1-3) Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl

              15:14:07,901 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-3) Quartz Scheduler v.1.6.1-RC1 created.

               

               

              Code:

               

              SessionFactory factory= new Configuration().configure().buildSessionFactory();

              factory.openSession();

               

               

               

              Thank you for your time and help.

              • 4. Re: Upgrade to Jboss7.1 Hibernate issue
                smarlow

                Public forums are the right place to ask for help.  When binding objects to JNDI, try to avoid "java:hibernate" (not a valid location in AS7). 

                 

                The following is from the EE 6 platform spec:

                EE.5.2.2Application Component Environment Namespaces

                 

                The application component’s naming environment is composed of four logical namespaces, representing naming environments with different scopes. The four namespaces are:

                 

                •java:comp - Names in this namespace are per-component (for example, per enterprise bean). Except for components in a web module, each component gets its own java:comp namespace, not shared with any other component. Components in a web module do not have their own private component namespace. See note below.

                 

                •java:module - Names in this namespace are shared by all components in a module (for example, all enterprise beans in a single EJB module, or all components in a web module).

                 

                •java:app - Names in this namespace are shared by all components in all modules in a single application, where “single application” means a single deployment unit, such as a single ear file, a single module deployed standalone, etc. For example, a war file and an EJB jar file in the same ear file would both have access to resources in the java:app namespace.

                 

                •java:global - Names in this namespace are shared by all applications deployed in an application server instance. Note that an application server instance may represent a single server, a cluster of servers, an administrative domain containing many servers, or even more. The scope of an application server instance is product-dependent, but it must be possible to deploy multiple applications to a single application server instance.

                 

                .

                .

                .

                 

                Instead, try something like "java:app/SessionFactory".  There is also the "java:jboss" namespace which is shared across applications.

                • 5. Re: Upgrade to Jboss7.1 Hibernate issue
                  thinksteep

                  Agree. It was due to desparation. Sorry!

                   

                  Let me try this suggestion.

                   

                  Thanks again for your time and help.

                   

                  Thank you,

                  • 6. Re: Upgrade to Jboss7.1 Hibernate issue
                    thinksteep

                    Hi Scott,

                     

                    Your suggestion worked and I am not seeing JNDI exception now. But while navigating through application, I am getting following error. Could you please help me where I might be wrong? Thanks for your time and help.

                     

                    I have created discussion on this issue with more logs.

                    https://community.jboss.org/thread/197313

                     

                     

                    12:00:26,472 ERROR [yyy_common.yyyUserActivityException] (http--127.0.0.1-8080-2) [yyyUserActivity][yyyUserActivityException][myBean][createConnection] Failed to create connection: org.hibernate.exception.GenericJDBCException: error performing isolated work

                        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.engine.transaction.Isolater$JdbcDelegate.delegateWork(Isolater.java:207) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:43) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:51) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.id.TableGenerator.generate(TableGenerator.java:94) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.javand(AbstractSaveEventListener.java:99) [hibernate3.jar:3.2.6.ga]

                        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) [hibernate3.jar:3.2.6.ga]

                     

                     

                    Thank you for your time and help.

                    • 7. Re: Upgrade to Jboss7.1 Hibernate issue
                      smarlow

                      If you google for the error, I think you will find that you cannot use TableHiLoGenerator this way (I think the active JTA transaction is coming from your bean class).  You probably don't want the JTA transaction to be active when your calling this code.

                       

                      Scott

                      • 8. Re: Upgrade to Jboss7.1 Hibernate issue
                        thinksteep

                        Hi Scott,

                         

                        Thanks for quick reply!

                         

                        I am reading about your pointer on this issue. May end up change to someother generator type.

                         

                        Actually I have another question,

                        1) While upgrading from 4.2.3a to 7.1 we have removed following entries from hibernate.cfg.xml, could this be causing the issue?

                        2) Where do these entries go in 7.1 configuration?

                        3) What are the subsitute configurations if these are not supported in 7.1

                        4) Can we safely ignore these while porting (if not required)

                         

                        Please help.

                         

                        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

                        <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup
                           </property>

                         

                        Thank you for your time and help.