简体   繁体   中英

Tomcat slow startup due to hibernate

Currently using Tomcat 6 and hibernate 3 for my application but I notice the startup is very slow,I only have about 40 entities mapped. Not sure if this is caused by hibernate the logs are below:

It takes around 5 mins for the below:

Any ideas? btw I have already tried increasing tomcat memory

2016-03-01 09:18:53,933  INFO [main] SessionFactoryObjectFactory.addInstance(105) | Not binding factory to JNDI, no JNDI name configured
2016-03-01 09:24:42,046 DEBUG [main] GnrlLookupView.<clinit>(37) | Registering view: GnrlLookupView
2016-03-01 09:24:46,881  INFO [main] QuartzScheduler.<init>(209) | Quartz Scheduler v.1.6.0 created.

Hibernate config:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource"> <ref bean="dataSource" /> </property>
    <property name="mappingJarLocations">
        <list>
            <value>WEB-INF/lib/*-hbm.jar</value>
        </list> 
    </property>
    <property name="lobHandler">
        <bean class="org.springframework.jdbc.support.lob.OracleLobHandler">
            <property name="nativeJdbcExtractor">
                <bean class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />
            </property>
        </bean>
    </property>     
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            <prop key="hibernate.connection.SetBigStringTryClob">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>  <!-- Explicitly enabled 2nd level cache since upgrade to hibernate version 3.2.x -->
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
        </props>
    </property>

    <property name="entityInterceptor">
        <ref bean="entityAuditInterceptor" />
    </property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> 
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref local="sessionFactory" />
    </property>
</bean>ref bean="entityAuditInterceptor" />
    </property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> 
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref local="sessionFactory" />
    </property>
</bean>

UPDATE : I've enabled finer logging and came to the below, it prints out the below for 5 mins, any idea?

SessionFactoryUtils.doGetSession(316) | Opening Hibernate Session
2016-03-01 10:46:45,468 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,468 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,468 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,483 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,483 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string
2016-03-01 10:46:45,483 DEBUG [main] OracleLobHandler.getClobAsString(229) | Returning Oracle CLOB as string

2016-03-01 10:44:43,487 DEBUG [main] HibernateTemplate.flushIfNecessary(389) | Eagerly flushing Hibernate session
2016-03-01 10:44:43,487 DEBUG [main] SessionFactoryUtils.closeSession(789) | Closing Hibernate Session
2016-03-01 10:44:43,487 DEBUG [main] SessionFactoryUtils.doGetSession(316) | Opening Hibernate Session

找到不是由于休眠设置的答案,似乎在启动应用程序期间,应用程序正在加载大量表并尝试保存在缓存中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM