Hi,
JBoss 配置了 20 多个 Web 应用(都使用了 Spring Framework),在 JBoss 启动的时候,在 boot.log 里面见到这 20 个都打印了一个 "[DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory", 然后要等差不多 10 分钟才转到下一个输出,
请问可以让应用启动快一点吗??可以禁止这些 Pre-instantiating singletons 吗??如何配置??
我给 JBoss 配置了 800MB 内存都搞得 Out Of Memory : Java Heap Space 了,
这个 Out Of Memory 是在初始化这些类的时候已经出现,是否与 lazy-init 配置有关??请帮下忙。谢谢。
因为不可能每个应用都用到所有的类,所有我觉得并不需要每个应用都需要 Pre-instantiating singletons, 请问这个是否合理以及如何配置?
下面为 boot.log 里面的日志输出:
16:18:05,973 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5aeecf0a: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.service.factory.FactoryBeanListenerManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.http.HttpBindingFactory,org.apache.cxf.binding.object.ObjectBindingFactory,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.management.InstrumentationManager,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.jms.JMSTransportFactory,org.apache.cxf.transport.local.LocalTransportFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.ws.policy.AssertionBuilderRegistry,org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry,org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry,org.apache.cxf.ws.policy.attachment.external.EndpointReferenceDomainExpressionBuilder,org.apache.cxf.ws.policy.PolicyBuilder,org.apache.cxf.ws.policy.PolicyEngine,org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider,org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider,org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder,org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMManager,org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider,org.apache.cxf.ws.rm.policy.RMAssertionBuilder,org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader,org.jboss.wsf.stack.cxf.addons.transports.httpserver.HttpServerTransportFactory]; root of factory hierarchy
.....//下一行日志输出要等几分钟
谢谢。
------解决思路----------------------
延迟初始化能行?
------解决思路----------------------
<beans default-init-lazy="true">试试懒加载初始化bean
------解决思路----------------------
延迟加载估计不靠谱。
如果你确信不是程序代码本身的问题,我很多年前碰到过tomcat出现同样的问题,
当时的解决方法是:
1. 把各个webapp里面共有的jar包放到tomcat的\common\lib下面,删除webapp各自的共有部分
2.换了jvm的实现——把sun的换成jrocket。
不知道是否有参考价值。