9

my application service is not able to start or respond to even warmup requests as the time taken by Jersey to scan the libraries is inordinate.

I have created application and hardcoded all the paths of the Resources for jersey.

<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.livily.rest.JerseyApplication</param-value>
</init-param>

Jersey Application has all the classes

public Set<Class<?>> getClasses()
{
Set<Class<?>> s = new HashSet<Class<?>>();
s.add(com.livily.rest.visitor.UserRatingUtil.class);
}

However, jersey is scanning for lot of providers

Mar 8, 2013 3:39:40 PM com.sun.jersey.core.spi.component.ProviderServices getServiceClasses
CONFIG:     Provider found: class com.sun.jersey.server.impl.model.parameter.multivalued.StringReaderProviders$StringConstructor

It is doing it about 50-100 times and then

Mar 8, 2013 3:39:41 PM com.sun.jersey.server.impl.modelapi.annotation.IntrospectionModeller createResource
FINEST: A new abstract resource created by IntrospectionModeler: AbstractResource("/current-status", - CurrentStatus: 1 constructors, 0 fields, 0 setter methods, 1 res methods, 0 subres methods, 0 subres locators )

for each one

The time taken in total is about 4-10 secs and appengine does not like this as it expects to wrap up the loading quickly; otherwise it starts giving weird 500 errors (for even static files).

I am stumped; any help will be appreciated.

Lipis
  • 21,388
  • 20
  • 94
  • 121
cloudpre
  • 1,001
  • 2
  • 15
  • 28
  • Not an answer, but I had similar load time issues with jersey and I moved to RestExpress (https://github.com/RestExpress/RestExpress), which doesn't have any of the J2EE weight. – Will Mar 10 '13 at 17:58
  • Cloudpre - that's not a valid comment – Will Mar 13 '13 at 18:48
  • Lipis - I moved to restexpress and to my surprise, it was actually slower in load time. I still get deadline exceptions. What is the best way to figure out what is taking lot of startup time? I changed logger level to all and find lot of output. Is this the best way? – cloudpre Mar 13 '13 at 19:43
  • what other libraries are you using? – Will Mar 13 '13 at 23:22
  • appengine, apps-marketplace, appengine-api-labs, guava, jackson-mapper, resteasy, joda-time-1.6, jsoup, commons-lang, objectify (about 20 registrations), jackson-core, openid4java, gson, mustache-compiler, scannotation, jsr107cache, commons-logging, asm. Nothing unusual. I use 1.7.5 and jar all the classes under WEB-INF. – cloudpre Mar 14 '13 at 11:17
  • Moving to F4 is one workaround for this mid-size app. – cloudpre Mar 14 '13 at 14:55

2 Answers2

1

I use the packages property to name which packages should be scanned as follows...

    <init-param>
         <param-name>com.sun.jersey.config.property.packages</param-name>
         <param-value>com.foo.myproviders</param-value>
    </init-param>
JayTee
  • 1,209
  • 9
  • 15
  • Jaytee - packages scanning are in fact slower than explicit defining the classes in the JaxRS Application. – cloudpre Mar 20 '13 at 04:16
  • how can you explicit define the classes in JaxRS Application? I thought the package scanning was the only possibility – Michele Orsi Aug 24 '13 at 07:13
1

Set jersey.config.disableAutoDiscovery. See Configuration Properties for details.

<init-param>
    <param-name>jersey.config.disableAutoDiscovery</param-name>
    <param-value>true</param-value>
</init-param>
Takahiko Kawasaki
  • 18,118
  • 9
  • 62
  • 105