Issue Details (XML | Word | Printable)

Key: JERSEY-1317
Type: Bug Bug
Status: Resolved Resolved
Resolution: Invalid
Priority: Major Major
Assignee: Michal Gajdos
Reporter: gamliela
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
jersey

Tomcat 7 slow startup time with Jersey (1.13) deployed

Created: 27/Jul/12 12:46 PM   Updated: 08/Aug/13 03:38 PM   Resolved: 03/Aug/12 09:31 AM
Component/s: containers
Affects Version/s: 1.13
Fix Version/s: 1.17

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Remaining Estimate - 0 minutes
Time Spent: 5 hours
Time Spent - 5 hours

Environment:

Windows 7, jdk1.6.0_30, apache-tomcat-7.0.29, jersey-archive-1.13, eclipselink-2.3.1


Tags: tomcat selenium eclipselink
Participants: gamliela, Marek Potociar and Michal Gajdos


 Description  « Hide

Time for launch Tomcat without Jersey is 1 second.
When I add the jars of Jersey to tomcat/lib directory, the time for launch goes for 30 seconds.
It doesn't matter which application I deploy - even if no application is deployed (no servlets) it takes that time. However the server already contains jars of Selenium and EclipseLink.

The jar that cause the problem is jersey-servlet-1.13. When I remove it from lib directory, launch time goes normal again. I suspect that the services defined in that jar (\META-INF\services*) cause the trouble but couldn't find the exact cause...

I'm not sure if it's a bug but it's definitively a problem.
My motivation for choosing Tomcat was performance, and if Jersey hurts that performance it's a problem.

Steps to reproduce:
1. download and extract apache-tomcat-7.0.29
2. copy to tomcat/lib directory the following jars from eclipselink-2.3.1 (JPA):
a) eclipselink.jar
b) javax.persistence_2.0.3.v201010191057.jar
3. copy to tomcat/lib directory the following jars from selenium-2.24.1:
a) selenium-java-2.24.1.jar
b) all jars from lib directory (36 jars)
4. run tomcat/bin/startup.bat and make sure (using logs) the startup time is few seconds at most.
On my machine it takes less than 1 second.
5. run shutdown.bat
6. copy to tomcat/lib directory the following jars from jersey-archive-1.12.zip:
a) asm-3.1.jar
b) jersey-core-1.12.jar
c) jersey-server-1.12.jar
d) jersey-servlet-1.12.jar
(As far as I know this is the minimum required to use Jersey)
7. run startup.bat again.
On my machine it takes now more than 30 seconds.



gamliela added a comment - 27/Jul/12 12:48 PM - edited

The same problem occurs on both versions of Jersey - 1.12 & 1.13.
Also please fix the download link for 1.13 (it still points to 1.12).


Marek Potociar added a comment - 02/Aug/12 11:45 AM

Michal, can you please evaluate?


Michal Gajdos added a comment - 03/Aug/12 09:31 AM - edited

This is not a Jersey bug although the jersey-servlet.jar makes Tomcat to perform some additional classpath scanning. The jersey-servlet.jar adds a capability for Servlet3 initialization which Tomcat7 supports. Since you put Jersey jars into tomcat/lib directory then the Jersey implementation of ServletContainerInitializer is invoked for every webapp (present in tomcat\webapps) during it's deployment. Before the invocation of the JerseyServletContainerInitializer the Tomcat does classpath scanning to provide requested classes to this initializer (which slows down the startup).

There are two ways to solve this issue:

  • if you do not need/use Servlet3 capabilities, you can remove the META-INF/services/javax.servlet.ServletContainerInitializer file from jersey-servlet.jar so that the JerseyServletContainerInitializer is not recognized by Tomcat and hence no classpath scanning is performed for this initializer.
  • if you want to use Servlet3 then pack the Jersey jars with the webapp to ensure the JerseyServletContainerInitializer is invoked only for this webapp (Tomcat will do the classpath scanning only for webapps containing the jersey-servlet.jar)

Edit: Thanks for noticing the incorrect download link.