users@glassfish.java.net

Re: Overriding jersey behaviour in GF4

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 3 Mar 2014 16:14:17 +0100

Unfortunately, there is no workaround in GF4 (AFAIK) because in GF you cannot override classes from system-level modules with application-level classes.
As such, JAX-RS 2.0 classes are loaded from GF system modules and since Jersey 1.x does not implement all JAX-RS 2.0 APIs, you will start running into these errors. Therefore you may need to migrate your application to Jersey 2.x in order to run it in GF4.

The first thing to do is to get rid of Jersey 1.x classes in your war and change your web.xml to use Jersey 2.x ServletContainer (or switch to Servlet 3.x-based deployment-free initialization):
https://jersey.java.net/documentation/latest/deployment.html#deployment.servlet

Here are some additional hints how to migrate your application:
https://jersey.java.net/documentation/latest/migration.html#mig-1.x

HTH,
Marek

On 02 Mar 2014, at 23:57, Reza Rahman <Reza.Rahman_at_oracle.com> wrote:

> I would start in the Jersey forums for this.
>
> On 3/2/2014 5:04 PM, Florent THOMAS wrote:
>> Hy everyone,
>>
>> I'm used to work with GF3.1.x and a .war application.
>> Recently I've upgrade with GF4 and it's not working anymore.
>> The problem seems to come from the configuration needed by the app :
>> https://bitbucket.org/sdorra/scm-manager/wiki/applicationserver
>>
>> It's necessary to override the GF conf with
>> bin/asadmin create-jvm-options -Dcom.sun.enterprise.overrideablejavaxpackages=javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext
>>
>> With or without this option, it's possible to install.
>> But when restarting GF4 I have this issue :
>> [javax.enterprise.web] [tid: _ThreadID=58 _ThreadName=http-listener-1(3)] [timeMillis: 1393282939373] [levelValue: 900] [[
>> StandardWrapperValve[default]: Servlet.service() for servlet default threw exception
>> java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
>> at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
>> at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:651)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
>>
>> It looks like overriding the use of jersey (1.x for the app) is not compatible with the new 2.x embedded in GF4.
>>
>> Is there any workaround for this?
>>
>> regards
>