Announcement Announcement Module
Collapse
No announcement yet.
Slooooow (18minutes) WebApplicationContext initialization! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Slooooow (18minutes) WebApplicationContext initialization!

    I'm using Spring 1.2.3 with Hibernate 3.0.5 on Tomcat 5.0.28. My applicationContext.xml has 60 beans. The WebApplicationContext takes 18+ minutes to startup! The slowest part is building the SessionFactory:

    Code:
    09:16:55 INFO  [AbstractBeanFactory:getBean:222] - Creating shared instance of singleton bean 'sessionFactory'
    09:23:56 INFO  [LocalSessionFactoryBean:afterPropertiesSet:691] - Building new Hibernate SessionFactory
    The weirdest part is that on the other developers' computers, the whole initialization only takes 2-3 minutes!

    I'm using Linux, and I tried both Java 1.4.2_08 and 1.5.0_03, and changing the VM didn't make any difference.

    Anybody seen this problem? Any tips? This wait is really slowing me down...

    Thanks in advance,
    Daniel Serodio

  • #2
    Just guessing; is your machine hanging whilst trying to open the jdbc connection to the database?

    Comment


    • #3
      You can try setting Spring logging to debug, so that you can see in more detail what's happening.

      Also, showing us your datasource and sessionfactory spring configuration might help.

      Comment


      • #4
        XML parsing

        Apparently, it 's the XML parsing that's slow. If I "pause" Tomcat via Eclipse debugger, I can see that it is running some Xerces method.

        Maybe it's trying to validate the Hibernate mapping files? Can I turn validation off?

        Code:
        	<!-- Local DataSource that works in any environment -->
        	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        		<property name="driverClassName"><value>$&#123;jdbc.driverClassName&#125;</value></property>
        		<property name="url"><value>$&#123;jdbc.url&#125;</value></property>
        		<property name="username"><value>$&#123;jdbc.username&#125;</value></property>
        		<property name="password"><value>$&#123;jdbc.password&#125;</value></property>
        	</bean>
        
        	<!-- Hibernate SessionFactory -->
        	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        		<property name="dataSource" ref="dataSource"/>
        		<property name="mappingResources">
        			<list> 
        				<value>br/com/econsulting/excelencia/bo/BaseBO.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/bo/Processo.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/bo/UnidadeOrganizacional.hbm.xml</value>				
        				<value>br/com/econsulting/excelencia/bo/UnidadeOrganizacionalAnterior.hbm.xml</value>				
        				<value>br/com/econsulting/excelencia/bo/Posicao.hbm.xml</value>								
        				<value>br/com/econsulting/excelencia/bo/PosicaoAnterior.hbm.xml</value>		
        
        				<value>br/com/econsulting/excelencia/bo/Colaborador.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/bo/ColaboradorAnterior.hbm.xml</value>	
        				
        				<value>br/com/econsulting/excelencia/bo/Modulo.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/bo/ArquivoAnexo.hbm.xml</value>
        
        				<value>br/com/econsulting/excelencia/bo/Aceite.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/bo/GrupoDeAcesso.hbm.xml</value>
        
        				<value>br/com/econsulting/excelencia/documentacao/bo/Documento.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/Arquivo.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/RevisaoDocumento.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/DadosRevisaoDocumentoFormal.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/DadosExclusaoFormal.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/TipoDocumento.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/Local.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/LocalDistribuicaoMeioFisico.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/CategoriaDocumento.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/SubCategoriaDocumento.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/EstadoRevisao.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/documentacao/bo/Pasta.hbm.xml</value>				
        
        				<value>br/com/econsulting/excelencia/melhoria/bo/Acao.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/AcompanhamentoAcao.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/AnaliseDeCausa.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/CategoriaOcorrencia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/EstadoAcao.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/EstadoOcorrencia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/EstadoPlanoAcao.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/ItemNorma.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/Norma.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/Ocorrencia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/OrigemOcorrencia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/PlanoDeAcao.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/ResultadoAceiteVerificacaoEficacia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/SubCategoriaOcorrencia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/CriterioVerificacaoEficacia.hbm.xml</value>
        				<value>br/com/econsulting/excelencia/melhoria/bo/VerificacaoEficacia.hbm.xml</value>
        
        				<!-- Aqui começam os mapeamentos do jBPM -->
        				<value>org/jbpm/identity/User.hbm.xml</value>
        		        <value>org/jbpm/identity/Group.hbm.xml</value>
        		        <value>org/jbpm/identity/Membership.hbm.xml</value>
        
        		        <!-- graph.def mapping files -->
        		        <value>org/jbpm/graph/def/ProcessDefinition.hbm.xml</value>
        		        <value>org/jbpm/graph/def/Node.hbm.xml</value>
        		        <value>org/jbpm/graph/def/Transition.hbm.xml</value>
        		        <value>org/jbpm/graph/def/Event.hbm.xml</value>
        		        <value>org/jbpm/graph/def/Action.hbm.xml</value>
        		        <value>org/jbpm/graph/def/SuperState.hbm.xml</value>
        		        <value>org/jbpm/graph/def/ExceptionHandler.hbm.xml</value>
        		        <value>org/jbpm/instantiation/Delegation.hbm.xml</value>
        
        		        <!-- graph.node mapping files -->
        		        <value>org/jbpm/graph/node/StartState.hbm.xml</value>
        		        <value>org/jbpm/graph/node/EndState.hbm.xml</value>
        		        <value>org/jbpm/graph/node/ProcessState.hbm.xml</value>
        		        <value>org/jbpm/graph/node/Decision.hbm.xml</value>
        		        <value>org/jbpm/graph/node/Fork.hbm.xml</value>
        		        <value>org/jbpm/graph/node/Join.hbm.xml</value>
        		        <value>org/jbpm/graph/node/State.hbm.xml</value>
        		        <value>org/jbpm/graph/node/TaskNode.hbm.xml</value>
        
        		        <!-- graph.action mapping files -->
        		        <value>org/jbpm/graph/action/Script.hbm.xml</value>
        
        		        <!-- context.def mapping files -->
        		        <value>org/jbpm/context/def/ContextDefinition.hbm.xml</value>
        		        <value>org/jbpm/context/def/VariableAccess.hbm.xml</value>
        
        		        <!-- taskmgmt.def mapping files -->
        		        <value>org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/def/Swimlane.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/def/Task.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/def/TaskController.hbm.xml</value>
        
        		        <!-- module.def mapping files -->
        		        <value>org/jbpm/module/def/ModuleDefinition.hbm.xml</value>
        
        		        <!-- bytes mapping files -->
        		        <value>org/jbpm/bytes/ByteArray.hbm.xml</value>
        
        		        <!-- file.def mapping files -->
        		        <value>org/jbpm/file/def/FileDefinition.hbm.xml</value>
        
        		        <!-- scheduler.def mapping files -->
        		        <value>org/jbpm/scheduler/def/CreateTimerAction.hbm.xml</value>
        		        <value>org/jbpm/scheduler/def/CancelTimerAction.hbm.xml</value>
        
        		        <!-- graph.exe mapping files -->
        		        <value>org/jbpm/graph/exe/Comment.hbm.xml</value>
        		        <value>org/jbpm/graph/exe/ProcessInstance.hbm.xml</value>
        		        <value>org/jbpm/graph/exe/Token.hbm.xml</value>
        		        <value>org/jbpm/graph/exe/RuntimeAction.hbm.xml</value>
        
        		        <!-- module.exe mapping files -->
        		        <value>org/jbpm/module/exe/ModuleInstance.hbm.xml</value>
        
        		        <!-- context.exe mapping files -->
        		        <value>org/jbpm/context/exe/ContextInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/TokenVariableMap.hbm.xml</value>
        		        <value>org/jbpm/context/exe/VariableInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml</value>
        		        <value>org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml</value>
        
        		        <!-- taskmgmt.exe mapping files -->
        		        <value>org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/exe/PooledActor.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml</value>
        
        		        <!-- scheduler.exe mapping files -->
        		        <value>org/jbpm/scheduler/exe/Timer.hbm.xml</value>
        
        		        <!-- logging mapping files -->
        		        <value>org/jbpm/logging/log/ProcessLog.hbm.xml</value>
        		        <value>org/jbpm/logging/log/MessageLog.hbm.xml</value>
        		        <value>org/jbpm/logging/log/CompositeLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/ActionLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/NodeLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/SignalLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/TokenCreateLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/TokenEndLog.hbm.xml</value>
        		        <value>org/jbpm/graph/log/TransitionLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/VariableLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/VariableCreateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/VariableDeleteLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/VariableUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/TaskLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml</value>
        		        <value>org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml</value>
        			</list>
        		</property>
        		<property name="hibernateProperties">
        			<props>
        				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
        				<prop key="hibernate.show_sql">$&#123;hibernate.show_sql&#125;</prop>
        				<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
        				<prop key="hibernate.hbm2ddl.auto">update</prop>
        				<prop key="hibernate.c3p0.minPoolSize">$&#123;hibernate.c3p0.minPoolSize&#125;</prop>
        				<prop key="hibernate.c3p0.maxPoolSize">$&#123;hibernate.c3p0.maxPoolSize&#125;</prop>
        				<prop key="hibernate.c3p0.timeout">$&#123;hibernate.c3p0.timeout&#125;</prop>
        				<prop key="hibernate.c3p0.max_statement">$&#123;hibernate.c3p0.max_statement&#125;</prop>
        			</props>
        		</property>
        	</bean>
        jdbc.properties:
        Code:
        jdbc.driverClassName=com.mysql.jdbc.Driver
        jdbc.url=jdbc&#58;mysql&#58;//localhost/eol
        hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
        
        jdbc.username=eol
        jdbc.password=
        
        hibernate.show_sql=false
        
        #Connection Pooling
        hibernate.c3p0.minPoolSize=5
        hibernate.c3p0.maxPoolSize=20
        hibernate.c3p0.timeout=1800
        hibernate.c3p0.max_statement=50
        log:
        Code:
        12&#58;53&#58;20 INFO  &#91;XmlBeanDefinitionReader&#58;loadBeanDefinitions&#58;150&#93; - Loading XML bean definitions from class path resource &#91;applicationContext.xml&#93;
        12&#58;53&#58;21 DEBUG &#91;JbpmConfiguration&#58;getProperties&#58;28&#93; - jbpm.task.instance.class=org.jbpm.taskmgmt.exe.TaskInstance
        12&#58;53&#58;21 DEBUG &#91;JbpmConfiguration&#58;getProperties&#58;28&#93; - jbpm.scheduler.service.factory=org.jbpm.scheduler.impl.SchedulerServiceImpl
        12&#58;53&#58;31 INFO  &#91;AbstractRefreshableApplicationContext&#58;refreshBeanFactory&#58;90&#93; - Bean factory for application context &#91;Root WebApplicationContext&#93;&#58; org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;propertyConfigurer,dataSource,sessionFactory,hibernateTemplate,contextCollector,jbpmSessionFactory,servicoWorkflow,servicoWorkflowDocumentacao,servicoWorkflowMelhoria,servicoColaborador,servicoImportacaoSap,servicoProcesso,servicoGrupoAcesso,servicoDocumentacao,fachadaNegociosDocumentacao,servicoMelhoria,fachadaNegociosMelhoria,jbpmSessionUtils,servicoExcelencia,fachadaRebirt,transactionManager,transactionTemplate,autoProxyCreator,transactionAttributes,transactionInterceptor,entidadeDAO,colaboradorDAO,importacaoDigester,importacaoSapDAO,grupoAcessoDAO,documentoDAO,revisaoDocumentoDAO,processoDAO,categoriaDAO,subcategoriaDAO,pastaDAO,localDAO,localDistribuicaoMeioFisicoDAO,tipoDocumentoDAO,aceiteDAO,estadoRevisaoDAO,dadosExclusaoFormalDAO,moduloDAO,rebirtDAO,primaryKeyConvertor,acaoDAO,acompanhamentoAcaoDAO,analiseDeCausaDAO,categoriaOcorrenciaDAO,estadoAcaoDAO,estadoOcorrenciaDAO,estadoPlanoAcaoDAO,itemNormaDAO,normaDAO,ocorrenciaDAO,origemOcorrenciaDAO,planoDeAcaoDAO,subCategoriaOcorrenciaDAO,criterioVerificacaoEficaciaDAO,resultadoAceiteVerificacaoEficaciaDAO&#93;; root of BeanFactory hierarchy
        12&#58;53&#58;32 INFO  &#91;AbstractApplicationContext&#58;refresh&#58;294&#93; - 60 beans defined in application context &#91;Root WebApplicationContext&#93;
        12&#58;53&#58;32 INFO  &#91;AbstractBeanFactory&#58;getBean&#58;222&#93; - Creating shared instance of singleton bean 'propertyConfigurer'
        12&#58;53&#58;34 INFO  &#91;PropertiesLoaderSupport&#58;loadProperties&#58;167&#93; - Loading properties file from class path resource &#91;jdbc.properties&#93;
        12&#58;53&#58;34 INFO  &#91;CollectionFactory&#58;<clinit>&#58;61&#93; - JDK 1.4+ collections available
        12&#58;53&#58;34 INFO  &#91;CollectionFactory&#58;<clinit>&#58;66&#93; - Commons Collections 3.x available
        12&#58;53&#58;34 DEBUG &#91;CollectionFactory&#58;createLinkedMapIfPossible&#58;108&#93; - Creating java.util.LinkedHashMap
        12&#58;53&#58;34 INFO  &#91;AbstractBeanFactory&#58;getBean&#58;222&#93; - Creating shared instance of singleton bean 'autoProxyCreator'
        12&#58;53&#58;38 INFO  &#91;DefaultAopProxyFactory&#58;<clinit>&#58;59&#93; - CGLIB2 available&#58; proxyTargetClass feature enabled
        12&#58;53&#58;39 INFO  &#91;AbstractApplicationContext$BeanPostProcessorChecker&#58;postProcessAfterInitialization&#58;745&#93; - Bean 'autoProxyCreator' is not eligible for getting processed by all BeanPostProcessors &#40;for example&#58; not eligible for auto-proxying&#41;
        12&#58;53&#58;39 INFO  &#91;AbstractApplicationContext&#58;initMessageSource&#58;432&#93; - Unable to locate MessageSource with name 'messageSource'&#58; using default &#91;[email protected]5&#93;
        12&#58;53&#58;39 DEBUG &#91;CollectionFactory&#58;createLinkedSetIfPossible&#58;84&#93; - Creating java.util.LinkedHashSet
        12&#58;53&#58;39 INFO  &#91;AbstractApplicationContext&#58;initApplicationEventMulticaster&#58;454&#93; - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster'&#58; using default &#91;org.springframework.context.event.SimpleApplicationEventMulticaster@81018b&#93;
        12&#58;53&#58;40 INFO  &#91;UiApplicationContextUtils&#58;initThemeSource&#58;68&#93; - No ThemeSource found for &#91;Root WebApplicationContext&#93;&#58; using ResourceBundleThemeSource
        12&#58;53&#58;40 DEBUG &#91;CollectionFactory&#58;createLinkedMapIfPossible&#58;108&#93; - Creating java.util.LinkedHashMap
        12&#58;53&#58;40 INFO  &#91;DefaultListableBeanFactory&#58;preInstantiateSingletons&#58;260&#93; - Pre-instantiating singletons in factory &#91;org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;propertyConfigurer,dataSource,sessionFactory,hibernateTemplate,contextCollector,jbpmSessionFactory,servicoWorkflow,servicoWorkflowDocumentacao,servicoWorkflowMelhoria,servicoColaborador,servicoImportacaoSap,servicoProcesso,servicoGrupoAcesso,servicoDocumentacao,fachadaNegociosDocumentacao,servicoMelhoria,fachadaNegociosMelhoria,jbpmSessionUtils,servicoExcelencia,fachadaRebirt,transactionManager,transactionTemplate,autoProxyCreator,transactionAttributes,transactionInterceptor,entidadeDAO,colaboradorDAO,importacaoDigester,importacaoSapDAO,grupoAcessoDAO,documentoDAO,revisaoDocumentoDAO,processoDAO,categoriaDAO,subcategoriaDAO,pastaDAO,localDAO,localDistribuicaoMeioFisicoDAO,tipoDocumentoDAO,aceiteDAO,estadoRevisaoDAO,dadosExclusaoFormalDAO,moduloDAO,rebirtDAO,primaryKeyConvertor,acaoDAO,acompanhamentoAcaoDAO,analiseDeCausaDAO,categoriaOcorrenciaDAO,estadoAcaoDAO,estadoOcorrenciaDAO,estadoPlanoAcaoDAO,itemNormaDAO,normaDAO,ocorrenciaDAO,origemOcorrenciaDAO,planoDeAcaoDAO,subCategoriaOcorrenciaDAO,criterioVerificacaoEficaciaDAO,resultadoAceiteVerificacaoEficaciaDAO&#93;; root of BeanFactory hierarchy&#93;
        12&#58;53&#58;40 INFO  &#91;AbstractBeanFactory&#58;getBean&#58;222&#93; - Creating shared instance of singleton bean 'dataSource'
        12&#58;53&#58;40 DEBUG &#91;AbstractAutoProxyCreator&#58;getCustomTargetSource&#58;282&#93; - Checking for custom TargetSource for bean with name 'dataSource'
        12&#58;53&#58;41 INFO  &#91;DriverManagerDataSource&#58;setDriverClassName&#58;154&#93; - Loaded JDBC driver&#58; com.mysql.jdbc.Driver
        12&#58;53&#58;41 INFO  &#91;AbstractBeanFactory&#58;getBean&#58;222&#93; - Creating shared instance of singleton bean 'sessionFactory'
        12&#58;53&#58;41 DEBUG &#91;AbstractAutoProxyCreator&#58;getCustomTargetSource&#58;282&#93; - Checking for custom TargetSource for bean with name 'sessionFactory'
        12&#58;53&#58;42 DEBUG &#91;CollectionFactory&#58;createLinkedSetIfPossible&#58;84&#93; - Creating java.util.LinkedHashSet
        01&#58;01&#58;54 INFO  &#91;LocalSessionFactoryBean&#58;afterPropertiesSet&#58;691&#93; - Building new Hibernate SessionFactory

        Comment


        • #5
          If you are on a windows box, try control break to get stack dump at the point where it is taking a long time to see where it is. For linux, do a kill -3 pid.

          Your best bet is to enable the profiling for the jdk you are using.


          Dino

          Comment


          • #6
            I didn't know about kill -3, thanks for the tip.
            Here's the stack dump:
            Code:
            Full thread dump Java HotSpot&#40;TM&#41; Client VM &#40;1.5.0_03-b07 mixed mode&#41;&#58;
            
            "Low Memory Detector" daemon prio=1 tid=0x080da468 nid=0x656d runnable &#91;0x00000000..0x00000000&#93;
            
            "CompilerThread0" daemon prio=1 tid=0x080d8ba8 nid=0x656c waiting on condition &#91;0x00000000..0xaa02d028&#93;
            
            "Signal Dispatcher" daemon prio=1 tid=0x080d7fa0 nid=0x656b runnable &#91;0x00000000..0x00000000&#93;
            
            "JDWP Command Reader" daemon prio=1 tid=0x080d54d8 nid=0x6569 runnable &#91;0x00000000..0x00000000&#93;
            
            "JDWP Event Helper Thread" daemon prio=1 tid=0x080d4050 nid=0x6568 runnable &#91;0x00000000..0x00000000&#93;
            
            "JDWP Transport Listener&#58; dt_socket" daemon prio=1 tid=0x080d2530 nid=0x6567 runnable &#91;0x00000000..0xaa231580&#93;
            
            "Finalizer" daemon prio=1 tid=0x080c2ca0 nid=0x6563 in Object.wait&#40;&#41; &#91;0xaa40d000..0xaa40d7c0&#93;
            	at java.lang.Object.wait&#40;Native Method&#41;
            	- waiting on <0xaaa7cfb0> &#40;a java.lang.ref.ReferenceQueue$Lock&#41;
            	at java.lang.ref.ReferenceQueue.remove&#40;ReferenceQueue.java&#58;116&#41;
            	- locked <0xaaa7cfb0> &#40;a java.lang.ref.ReferenceQueue$Lock&#41;
            	at java.lang.ref.ReferenceQueue.remove&#40;ReferenceQueue.java&#58;132&#41;
            	at java.lang.ref.Finalizer$FinalizerThread.run&#40;Finalizer.java&#58;159&#41;
            
            "Reference Handler" daemon prio=1 tid=0x080c2028 nid=0x6562 in Object.wait&#40;&#41; &#91;0xaa48e000..0xaa48e740&#93;
            	at java.lang.Object.wait&#40;Native Method&#41;
            	- waiting on <0xaaa7cfd0> &#40;a java.lang.ref.Reference$Lock&#41;
            	at java.lang.Object.wait&#40;Object.java&#58;474&#41;
            	at java.lang.ref.Reference$ReferenceHandler.run&#40;Reference.java&#58;116&#41;
            	- locked <0xaaa7cfd0> &#40;a java.lang.ref.Reference$Lock&#41;
            
            "main" prio=1 tid=0x0805c6c8 nid=0x655b runnable &#91;0xbfffb000..0xbfffd518&#93;
            	at java.lang.String.charAt&#40;String.java&#58;557&#41;
            	at org.apache.xerces.impl.dtd.DTDGrammar$QNameHashtable.hash&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.dtd.DTDGrammar$QNameHashtable.get&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.dtd.DTDGrammar.getElementDeclIndex&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.dtd.XMLDTDProcessor.attributeDecl&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDTDScannerImpl.scanAttlistDecl&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDTDScannerImpl.scanDecls&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDTDScannerImpl.scanDTDExternalSubset&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.XML11Configuration.parse&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.XML11Configuration.parse&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.XMLParser.parse&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.AbstractSAXParser.parse&#40;Unknown Source&#41;
            	at org.dom4j.io.SAXReader.read&#40;SAXReader.java&#58;465&#41;
            	at org.hibernate.cfg.Configuration.addInputStream&#40;Configuration.java&#58;398&#41;
            	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet&#40;LocalSessionFactoryBean.java&#58;621&#41;
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;1003&#41;
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;348&#41;
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;226&#41;
            	- locked <0xaad1a968> &#40;a java.util.HashMap&#41;
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;147&#41;
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;269&#41;
            	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;317&#41;
            	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh&#40;AbstractRefreshableWebApplicationContext.java&#58;134&#41;
            	at org.springframework.web.context.ContextLoader.createWebApplicationContext&#40;ContextLoader.java&#58;230&#41;
            	at org.springframework.web.context.ContextLoader.initWebApplicationContext&#40;ContextLoader.java&#58;156&#41;
            	at org.springframework.web.context.ContextLoaderListener.contextInitialized&#40;ContextLoaderListener.java&#58;48&#41;
            	at org.apache.catalina.core.StandardContext.listenerStart&#40;StandardContext.java&#58;3827&#41;
            	at org.apache.catalina.core.StandardContext.start&#40;StandardContext.java&#58;4343&#41;
            	- locked <0xaac4f300> &#40;a org.apache.catalina.core.StandardContext&#41;
            	at org.apache.catalina.core.ContainerBase.addChildInternal&#40;ContainerBase.java&#58;823&#41;
            	- locked <0xaab4df78> &#40;a java.util.HashMap&#41;
            	at org.apache.catalina.core.ContainerBase.addChild&#40;ContainerBase.java&#58;807&#41;
            	at org.apache.catalina.core.StandardHost.addChild&#40;StandardHost.java&#58;595&#41;
            	at org.apache.catalina.core.StandardHostDeployer.addChild&#40;StandardHostDeployer.java&#58;903&#41;
            	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
            	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
            	at java.lang.reflect.Method.invoke&#40;Method.java&#58;585&#41;
            	at org.apache.commons.beanutils.MethodUtils.invokeMethod&#40;MethodUtils.java&#58;216&#41;
            	at org.apache.commons.digester.SetNextRule.end&#40;SetNextRule.java&#58;256&#41;
            	at org.apache.commons.digester.Rule.end&#40;Rule.java&#58;276&#41;
            	at org.apache.commons.digester.Digester.endElement&#40;Digester.java&#58;1058&#41;
            	at org.apache.catalina.util.CatalinaDigester.endElement&#40;CatalinaDigester.java&#58;76&#41;
            	at org.apache.xerces.parsers.AbstractSAXParser.endElement&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch&#40;Unknown Source&#41;
            	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.XML11Configuration.parse&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.XML11Configuration.parse&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.XMLParser.parse&#40;Unknown Source&#41;
            	at org.apache.xerces.parsers.AbstractSAXParser.parse&#40;Unknown Source&#41;
            	at org.apache.commons.digester.Digester.parse&#40;Digester.java&#58;1567&#41;
            	at org.apache.catalina.core.StandardHostDeployer.install&#40;StandardHostDeployer.java&#58;488&#41;
            	- locked <0xaabb4650> &#40;a org.apache.catalina.core.StandardHostDeployer&#41;
            	at org.apache.catalina.core.StandardHost.install&#40;StandardHost.java&#58;863&#41;
            	- locked <0xaab4c8f8> &#40;a org.apache.catalina.core.StandardHost&#41;
            	at org.apache.catalina.startup.HostConfig.deployDescriptors&#40;HostConfig.java&#58;483&#41;
            	at org.apache.catalina.startup.HostConfig.deployApps&#40;HostConfig.java&#58;427&#41;
            	at org.apache.catalina.startup.HostConfig.start&#40;HostConfig.java&#58;983&#41;
            	at org.apache.catalina.startup.HostConfig.lifecycleEvent&#40;HostConfig.java&#58;349&#41;
            	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent&#40;LifecycleSupport.java&#58;119&#41;
            	at org.apache.catalina.core.ContainerBase.start&#40;ContainerBase.java&#58;1091&#41;
            	- locked <0xaab4c8f8> &#40;a org.apache.catalina.core.StandardHost&#41;
            	at org.apache.catalina.core.StandardHost.start&#40;StandardHost.java&#58;789&#41;
            	- locked <0xaab4c8f8> &#40;a org.apache.catalina.core.StandardHost&#41;
            	at org.apache.catalina.core.ContainerBase.start&#40;ContainerBase.java&#58;1083&#41;
            	- locked <0xaab368d8> &#40;a org.apache.catalina.core.StandardEngine&#41;
            	at org.apache.catalina.core.StandardEngine.start&#40;StandardEngine.java&#58;478&#41;
            	at org.apache.catalina.core.StandardService.start&#40;StandardService.java&#58;480&#41;
            	- locked <0xaab368d8> &#40;a org.apache.catalina.core.StandardEngine&#41;
            	at org.apache.catalina.core.StandardServer.start&#40;StandardServer.java&#58;2313&#41;
            	- locked <0xaab57b48> &#40;a &#91;Lorg.apache.catalina.Service;&#41;
            	at org.apache.catalina.startup.Catalina.start&#40;Catalina.java&#58;556&#41;
            	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
            	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
            	at java.lang.reflect.Method.invoke&#40;Method.java&#58;585&#41;
            	at org.apache.catalina.startup.Bootstrap.start&#40;Bootstrap.java&#58;287&#41;
            	at org.apache.catalina.startup.Bootstrap.main&#40;Bootstrap.java&#58;425&#41;
            
            "VM Thread" prio=1 tid=0x080bf3f8 nid=0x6561 runnable 
            
            "VM Periodic Task Thread" prio=1 tid=0x080db8e0 nid=0x656e waiting on condition

            Comment


            • #7
              Eclipse!?!

              I tried starting Tomcat from outside Eclipse, and the ApplicationContext initialization took only 30 seconds! Damned Eclipse!

              What could be causing this? I'm using Eclipse 3.1 with WTP (Webtools) 0.7.

              Comment


              • #8
                Re: Slooooow (18minutes) WebApplicationContext initializatio

                Hi,

                Use a mappingDirectoryLocation , it locates all .hbm.xml file and load for you automatically.
                But I dont think this is your main problem.

                Code:
                <bean id="sessionFactory"
                        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                        <property name="dataSource"><ref bean="dataSource"/>
                        </property>
                	    <property name="mappingDirectoryLocations">
                            <list>
                                <value>/your/xml/location/dir/</value>
                            </list>
                        </property>
                        <property name="hibernateProperties">
                            <props>
                                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                            </props>
                        </property>
                	</bean>
                Originally posted by dserodio
                I'm using Spring 1.2.3 with Hibernate 3.0.5 on Tomcat 5.0.28. My applicationContext.xml has 60 beans. The WebApplicationContext takes 18+ minutes to startup! The slowest part is building the SessionFactory:

                Code:
                09&#58;16&#58;55 INFO  &#91;AbstractBeanFactory&#58;getBean&#58;222&#93; - Creating shared instance of singleton bean 'sessionFactory'
                09&#58;23&#58;56 INFO  &#91;LocalSessionFactoryBean&#58;afterPropertiesSet&#58;691&#93; - Building new Hibernate SessionFactory
                The weirdest part is that on the other developers' computers, the whole initialization only takes 2-3 minutes!

                I'm using Linux, and I tried both Java 1.4.2_08 and 1.5.0_03, and changing the VM didn't make any difference.

                Anybody seen this problem? Any tips? This wait is really slowing me down...

                Thanks in advance,
                Daniel Serodio
                [/code]

                Comment


                • #9
                  Re: Eclipse!?!

                  I'm using Eclipse + WTP 0.7 too and everything goes fine here.

                  Bom saber que tem mais alguem aqui no Brasil que ta usando Spring tb!

                  Originally posted by dserodio
                  I tried starting Tomcat from outside Eclipse, and the ApplicationContext initialization took only 30 seconds! Damned Eclipse!

                  What could be causing this? I'm using Eclipse 3.1 with WTP (Webtools) 0.7.

                  Comment


                  • #10
                    The difference might be in which XML parser is used by Tomcat when running standalone.

                    Rob

                    Comment


                    • #11
                      Did you ever get a resolution on this? It just started happening for me yesterday, then it went away, now it's back!

                      Comment


                      • #12
                        I've never personally experienced this. From what your saying this isn't always a problem. It comes and goes randomly? Do you also have a large number of mapping files? Have you tried suspending the threads in eclipse and seeing where its stuck?

                        Comment


                        • #13
                          It happens when loading the bean definitions, and according to the suspended thread, it's in the process of creating the WebApplicationContext, as in:

                          Loading XML bean definitions from class path resource [domainLogicContext-comits.xml]

                          I know more information would be helpful, but I'm pretty sure it's an eclipse issue, since the server starts just fine outside of eclipse, and other developers aren't having this problem. It's not really random, as it's never happened before, but once, and I can't say for sure why it stopped, then started again...

                          Comment


                          • #14
                            After looking at it in debug a little more, it appears to be getting bogged down in Reflection, copying the methods of the beans...

                            Comment


                            • #15
                              I'm sure this is an eclipse issue. Seems like a strange one.

                              Comment

                              Working...
                              X