0

The project I am currently working on involves Tomcat servlet container hosting an application build of:

  • Hibernate as an ORM framework
  • Spring as middle tier
  • XLST transformations for web tier

Is there any way to speed mainly building hibernate entinty structers of Spring beans info or are there any common trick to speed up java enterprise web application startup?

Wojciech Owczarczyk
  • 5,595
  • 2
  • 33
  • 55

2 Answers2

1

As with everything else do a profiling and find out where you're really spending the time. Yes, Spring auto-detection can be slow in large applications but so can be eager initialization. Without profiling information you're just guessing what the problem is.

Philippe Marschall
  • 4,452
  • 1
  • 34
  • 52
1

Late to the game on an answer, but it if helps anyone: best thing I've found is go through your web.xml item by item and remove whatever bloat you can. This shaved off minutes for me. Profiling is also good as it can help you pinpoint expensive things like extra Hibernate session factories. Keep a lean POM to reduce classpath scanning time (use dependency tree). Using @Autowired is really handy, but if feasible and you have the time, go through your application and remove any unused references and unnecessary annotations. Same goes for component scanning. Make sure your DB connector is up to date. Much of the excessive startup time is often related to your specific application rather than modern Tomcat instances or the frameworks. If your application is huge and you can modularize them into different jars, you can simply load just the ones you need in dev for the task at the time.

Set your logging to WARN on noisy loggers. Adding TLD jars to skip in org.apache.catalina.startup.TldConfig.jarsToSkip in Tomcat 6/7 can also help. Native compile with APR didn't save startup time for me, though I'd imagine that helps a running container serving pages more than startup time. Also, disabling antiJARLocking/antiResourceLocking will speed up your Tomcat boot time.

You should be able to hit under a 15-second startup with Spring 4/Hibernate 4/Tomcat 7 and a moderately fast laptop.

Community
  • 1
  • 1
riddle_me_this
  • 8,575
  • 10
  • 55
  • 80