2

How to profile Spring application context loading?

Is there a way to profile the spring application context loading (except of putting the spring logs in DEBUG mode. Tried it already, I need something more fine grained)? In our application this takes long time, and I want to understand what are the reasons.

I already use the

context.setValidating(false); 
context.refresh(); // Load the context.

in order not to validate the XML schema of the spring xml files of beans definitions.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Genry
  • 1,358
  • 2
  • 23
  • 39
  • possible duplicate of [Profiling a Java Spring application](http://stackoverflow.com/questions/2475682/profiling-a-java-spring-application) – sheltem Jan 02 '14 at 15:55
  • @sheltem - read the post. I don't think this is a duplicate. I am interested not in profiling the ongoing application using Spring, but only the application context loading. It takes too long time to load the context. All the rest works fine. – Genry Jan 02 '14 at 15:59
  • Must be loading a lot of beans. – duffymo Jan 02 '14 at 16:02
  • By a quick look at source: `DefaultSingletonBeanRegistry#beforeSingletonCreation` and `DefaultSingletonBeanRegistry#afterSingletonCreation` might be good spots for the profiling logic. – Pavel Horal Jan 02 '14 at 16:11
  • You should be able to pin point the problem just from the DEBUG logs. Look for some delays between log messages about bean creation. – Pavel Horal Jan 02 '14 at 16:14

0 Answers0