Announcement Announcement Module
Collapse
No announcement yet.
Endless Loop Configuring Hibernate SessionFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Endless Loop Configuring Hibernate SessionFactory

    Hi!

    I am running a Spring application inside JBoss 3.2.5. I decided to play with the Hibernate integration, so I set up a simple DAO, and used a configuration very similar to what is in the docs.

    But when I start up my server, it appears to go into an endless loop, attempting to build my SessionFactory over and over again. Are there any obvious problems in the configuration?

    My springcontext.xml (which is loaded through a SingletonBeanFactoryLocator) contains the following:

    Code:
       <!-- Hibernate -->
       <bean id="bigdealDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName">
             <value>java&#58;/BigDealDS</value>
          </property>
       </bean>
    
       <bean id="bigdealSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
          <property name="mappingResources">
             <list>
                <value>bigdeal.hbm.xml</value>
             </list>
          </property>
          <property name="hibernateProperties">
             <props>
                <prop key="hibernate.dialect">net.sf.hibernate.dialect.FirebirdDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">create</prop>
                <prop key="hibernate.show_sql">true</prop>
             </props>
          </property>
          <property name="dataSource">
             <ref bean="bigdealDataSource"/>
          </property>
       </bean>
    
       <bean id="bigdealHibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
          <property name="sessionFactory">
             <ref bean="bigdealSessionFactory"/>
          </property>
       </bean>
    
       <bean id="userDaoTarget" class="com.blued.bigdeal.dao.UserDaoBean">
          <property name="sessionFactory">
             <ref bean="bigdealSessionFactory"/>
          </property>
       </bean>
    
       <bean id="userDao" class="org.springframework.aop.framework.ProxyFactoryBean">
          <property name="proxyInterfaces">
             <value>com.blued.bigdeal.dao.UserDao</value>
          </property>
          <property name="interceptorNames">
             <list>
                <value>bigdealHibernateInterceptor</value>
                <value>userDaoTarget</value>
             </list>
          </property>
       </bean>

    When I start up my server, the following messages are printed over and over in an endless loop:

    Code:
    16&#58;24&#58;26,173 INFO  &#91;Binder&#93; Mapping class&#58; com.blued.bigdeal.model.user.UserBean -> userTest
    16&#58;24&#58;26,283 INFO  &#91;LocalSessionFactoryBean&#93; Building new Hibernate SessionFactory
    16&#58;24&#58;26,283 INFO  &#91;Configuration&#93; processing one-to-many association mappings
    16&#58;24&#58;26,283 INFO  &#91;Configuration&#93; processing one-to-one association property references
    16&#58;24&#58;26,283 INFO  &#91;Configuration&#93; processing foreign key constraints
    16&#58;24&#58;26,298 INFO  &#91;Dialect&#93; Using dialect&#58; net.sf.hibernate.dialect.FirebirdDialect
    16&#58;24&#58;26,298 INFO  &#91;SettingsFactory&#93; Use outer join fetching&#58; true
    16&#58;24&#58;26,298 INFO  &#91;ConnectionProviderFactory&#93; Initializing connection provider&#58; org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
    16&#58;24&#58;26,314 INFO  &#91;TransactionManagerLookupFactory&#93; No TransactionManagerLookup configured &#40;in JTA environment, use of process level read-write cache is not recommended&#41;
    16&#58;24&#58;26,314 INFO  &#91;SettingsFactory&#93; Use scrollable result sets&#58; false
    16&#58;24&#58;26,314 INFO  &#91;SettingsFactory&#93; Use JDBC3 getGeneratedKeys&#40;&#41;&#58; false
    16&#58;24&#58;26,314 INFO  &#91;SettingsFactory&#93; Optimize cache for minimal puts&#58; false
    16&#58;24&#58;26,314 INFO  &#91;SettingsFactory&#93; echoing all SQL to stdout
    16&#58;24&#58;26,314 INFO  &#91;SettingsFactory&#93; Query language substitutions&#58; &#123;&#125;
    16&#58;24&#58;26,314 INFO  &#91;SettingsFactory&#93; cache provider&#58; net.sf.hibernate.cache.EhCacheProvider
    16&#58;24&#58;26,314 INFO  &#91;Configuration&#93; instantiating and configuring caches
    16&#58;24&#58;26,345 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'userDao'
    16&#58;24&#58;26,361 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'bigdealHibernateInterceptor'
    16&#58;24&#58;26,376 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'bigdealSessionFactory'
    I can not find any other reports of this problem searching the forums, so I must be doing something really dumb!

  • #2
    Ach, I found it. There was an exception (ClassNotFound) being thrown during the bean instantiation, but DefaultListableBeanFactory masks it in debug-level logging.

    Thanks anyway!

    Comment


    • #3
      RE: Endless Loop Configuring Hibernate SessionFactory

      Sorry but I see you had this issue sometime in 2004 - I am having the same. Didn't mean to resurrect the thread. But is there any way you can guide me to resolve this?

      Comment


      • #4
        Originally posted by losintikfos View Post
        Sorry but I see you had this issue sometime in 2004 - I am having the same. Didn't mean to resurrect the thread. But is there any way you can guide me to resolve this?
        Hi!

        You might want to set logging level to debug to see if that can tell you if you too get a ClassNotFound exception, and if so, please post the stacktrace.


        -Kaj

        Comment


        • #5
          I have added the following to my log4j.properties file but still dont get any exception, just a continous loop.

          #log4j.logger.org.hibernate=info
          log4j.logger.org.hibernate=debug

          ### log HQL query parser activity
          #log4j.logger.org.hibernate.hql.ast.AST=debug

          ### log just the SQL
          #log4j.logger.org.hibernate.SQL=debug

          ### log JDBC bind parameters ###
          log4j.logger.org.hibernate.type=info
          #log4j.logger.org.hibernate.type=debug

          ### log schema export/update ###
          log4j.logger.org.hibernate.tool.hbm2ddl=debug

          ### log HQL parse trees
          #log4j.logger.org.hibernate.hql=debug

          ### log cache activity ###
          #log4j.logger.org.hibernate.cache=debug

          ### log transaction activity
          #log4j.logger.org.hibernate.transaction=debug

          ### log JDBC resource acquisition
          #log4j.logger.org.hibernate.jdbc=debug

          ### enable the following line if you want to track down connection ###
          ### leakages when using DriverManagerConnectionProvider ###
          #log4j.logger.org.hibernate.connection.DriverManag erConnectionProvider=trac5

          Comment


          • #6
            Originally posted by kajh View Post
            Hi!

            You might want to set logging level to debug to see if that can tell you if you too get a ClassNotFound exception, and if so, please post the stacktrace.


            -Kaj
            I have taken hibernate and session related definitions out of my context xml. This upon run still loops but ends with this exception;

            Exception in thread "main" java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:946)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:890)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:479)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:450)
            at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 90)
            at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
            at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:287 )
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:189)
            at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:557)
            at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:842)
            at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:416)
            at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
            at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
            at com.port.billing.service.test.Testing.run(Testing. java:22)

            Comment


            • #7
              Sorry, no idea.

              Comment

              Working...
              X