users@jersey.java.net

Re: [Jersey] Initialization at startup, as opposed to first request?

From: Jeff Crump <jeffrey.crump_at_gmail.com>
Date: Thu, 10 Jun 2010 15:39:33 -0400

Thanks, this is exactly what I want. Works like a champ.

On 10 June 2010 14:07, Pavel Bucek <Pavel.Bucek_at_sun.com> wrote:

> Hello Jeff,
>
> you can control this in web.xml, concretely add load-on-startup into
> servlet element.
>
> Example:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"<http://java.sun.com/xml/ns/j2ee>xmlns:xsi=
> "http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance>xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"<http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd>
> >
> <servlet>
> <servlet-name>Jersey Web Application</servlet-name>
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.packages</param-name>
>
> <param-value>com.sun.jersey.samples.helloworld.resources</param-value>
> </init-param>
> *<load-on-startup>1</load-on-startup>*
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey Web Application</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
> Regards,
> Pavel
>
>
>
> On 6/10/10 7:44 PM, Jeff Crump wrote:
>
> I've noticed that the first request I send to my Jersey application takes a
> bit longer than subsequent ones -- I presume this is Jersey looking at my
> classes and assembling the infrastructure.
>
> Is there a way to force this initialization, say, when my servlet starts up
> - as opposed to on the first request?
>
> Thanks,
>
> Jeff
>
>
>