users@jersey.java.net

[Jersey] Re: hot class reloading

From: Libor Kramolis <libor.kramolis_at_oracle.com>
Date: Thu, 20 Mar 2014 09:55:07 +0100

Hi.
We do some experiments with Spring Loaded [1], it can reload changed classes. We are going to use it just during development phase, not in production. And also it does not reload Jersey JAX-RS model. It means if you changed your RESTful API (changed JAX-RS annotation usage) it is not automatically reloaded. You do have to call Container.reload() method [2]. See reload example [3].

Still not sure if it works in all cases. But we think about it just for development purposes...

Best regards,
-lk

[1] https://github.com/spring-projects/spring-loaded
[2] https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/server/spi/Container.html#reload()
[3] https://github.com/jersey/jersey/tree/master/examples/reload

On 20 Mar 2014, at 02:59, Oleksiy Stashok <oleksiy.stashok_at_oracle.com> wrote:
> Adding Jersey mailing list in case anyone has experience with that.
>
> Just my guess is that you probably have to split resources jar out of main jar and replace and reload only resources, not entire jar.
>
> Thanks.
>
> WBR,
> Alexey.
>
> On 18.03.14 13:26, Andrew Munn wrote:
>> What is the best way to reload some part of the web facing portion of an
>> app running in production without taking the Grizzly/Jersey server down?
>>
>> I'm doing this:
>>
>> Set<Class<?>> classes = new HashSet<>();
>> classes.add(myapp.MyClass.class);
>> classes.add(myapp.MyOtherClass.class);
>> ResourceConfig rc = new ResourceConfig(classes);
>> HttpServer httpServer =
>> GrizzlyHttpServerFactory.createHttpServer(BASE_URI, rc);
>> System.out.println(String.format("Jersey app started with WADL available
>> at " + "%sapplication.wadl", BASE_URI, BASE_URI));
>>
>> and tried to reload like this after replacing the running jar:
>>
>> GrizzlyHttpContainer c = (GrizzlyHttpContainer)httpServer.getHttpHandler();
>> c.reload();
>>
>> but no luck, just a ClassCastException. Will that method do what I want
>> and what's the preferred way to get a reference to it?
>>
>> Thanks!
>>
>>
>>
>