Tweak loading times of Jersey over AppEngine

空扰寡人 提交于 2019-12-06 22:34:01

问题


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.


回答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>



回答2:


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>


来源:https://stackoverflow.com/questions/15297961/tweak-loading-times-of-jersey-over-appengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!