users@jersey.java.net

[Jersey] Container reload: ResourceConfig is locked

From: Maarten Winkels <maarten.winkels_at_iwelcome.com>
Date: Mon, 1 Jul 2013 01:00:19 +0200

Hi All,

I would like to use Jersey 2.0 in a situation where resources are registered at runtime. I use this in an OSGi container, where bundles are installed and can register services that should be exposed as REST web services in Jersey.

In Jersey 1(.17.1) this worked fine, by 'reload'-ing the ServletContainer. If I try the same thing in Jersey 2.0, however, I get the following error:

java.lang.IllegalStateException: The resource configuration is not modifiable in this context.
        at org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:257)
        at org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:205)
        at org.glassfish.jersey.server.ResourceConfig.register(ResourceConfig.java:435)
        at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:261)
        at org.glassfish.jersey.servlet.ServletContainer.reload(ServletContainer.java:568)
        at org.glassfish.jersey.servlet.ServletContainer.reload(ServletContainer.java:562)

It seems that reloading of a (standard) ResourceConfig is no longer possible?
I have initialised the ResourceConfig.fromApplication(new MyApplication()).

It looks like the ResourceConfig is locked and can no longer be changed after initialisation. Even the ServletContainer.reload method cannot reload the resource config.

Is there any other way to implement my required behaviour?

Thanks in advance,

Maarten Winkels | IWelcome BV

Wiersedreef 5-7
3433 ZX Nieuwegein
The Netherlands

Tel: +31 (0) 30 6592254
Mob. +31 (0) 6 10038878
Email: maarten.winkels_at_iwelcome.com
Website: http://www.iwelcome.com





The information in this Internet email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this Internet email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. When addressed to our clients any opinions or advice contained in this Internet email are subject to the terms and conditions expressed in any applicable governing Everett terms of business or client engagement letter.