Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tweak loading times of Jersey over AppEngine

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.

like image 407
cloudpre Avatar asked Mar 08 '13 15:03

cloudpre


2 Answers

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>
like image 56
JayTee Avatar answered Nov 20 '22 14:11

JayTee


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>
like image 40
Takahiko Kawasaki Avatar answered Nov 20 '22 12:11

Takahiko Kawasaki