netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

New Jersey 3 module

Open javierllorente opened this issue 2 years ago • 11 comments

~~I have upgraded Jersey from 2.35 to 3.1.3. Related dependencies were upgraded and references to javax were switched to jakarta as well.~~

I have created a new module for Jersey 3 so that both Jersey 2 and 3 can co-exist.

javierllorente avatar Oct 17 '23 21:10 javierllorente

This will brake Java EE/Jakarta EE 8 and prior projects, maybe add another Library called Jersey 3.x.y?

pepness avatar Oct 17 '23 22:10 pepness

I haven't checked for what this is used for internally, but if its just a lib wrapper for ant projects (I have the suspicion it is more than that), i would update it to the latest javax release and leave it there. https://projects.eclipse.org/projects/ee4j.jersey/releases/2.40

mbien avatar Oct 18 '23 08:10 mbien

This will brake Java EE/Jakarta EE 8 and prior projects, maybe add another Library called Jersey 3.x.y?

Can we ship two Jersey versions without having conflicts?

javierllorente avatar Oct 18 '23 09:10 javierllorente

At some point we will have to upgrade to Jersey 3. Not sure if it's the right moment to do so. As a side note, I think that the Jersey version shipped by websvc.restlib breaks the REST Client plugin. See #6566.

javierllorente avatar Oct 18 '23 09:10 javierllorente

You can have different versions of the same library, check the Ant Library, there are different versions for JSF and Spring: Screenshot from 2023-10-18 11-58-52 I do not think it is as a matter of "upgrade" but of "support", we should support Jersey 2 for Java/Jakarta EE 8 and prior and add support for Jersey 3 for Jakarta EE 9 and onward.

I agree with @mbien, we should update it to the latest 2.x version.

pepness avatar Oct 18 '23 18:10 pepness

Ok, my take on this is:

a) jersey is broken because it relies on autodetection of features and does not protect against classes it can't load b) relying on autodiscovery is nice, but broken if you don't control the whole classpath

For "REST Client" I think the solution is trivial (CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE disabled auto detection):

    private void buildClient(boolean verifySslCertificates) {
        ClientConfig config = new ClientConfig()
                .connectorProvider(new ApacheConnectorProvider())
                .property(ClientProperties.CONNECT_TIMEOUT, 20000)
                .property(ClientProperties.FOLLOW_REDIRECTS, true)
                .property(CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
                .property(JsonGenerator.PRETTY_PRINTING, true)
                .register(new LoggingFeature(logger, Level.INFO, LoggingFeature.Verbosity.HEADERS_ONLY, 8192));
        client = verifySslCertificates
                ? ClientBuilder.newBuilder().withConfig(config).build()
                : ClientBuilder.newBuilder().sslContext(getSslContext()).withConfig(config).build();
    }

I checked the "Oracle Cloud Integration" module and it depends on the exported classes to be Jersey 2, this looks like a harder problem.

matthiasblaesing avatar Oct 21 '23 17:10 matthiasblaesing

You can have different versions of the same library, check the Ant Library, there are different versions for JSF and Spring:

[...]

I do not think it is as a matter of "upgrade" but of "support", we should support Jersey 2 for Java/Jakarta EE 8 and prior and add support for Jersey 3 for Jakarta EE 9 and onward.

I agree with @mbien, we should update it to the latest 2.x version.

Understood. Thanks for making it clear. It looks like a matter of having two different directories; ext/jersey2 and ext/jersey3. I'll take look at this.

javierllorente avatar Oct 23 '23 21:10 javierllorente

Ok, my take on this is:

a) jersey is broken because it relies on autodetection of features and does not protect against classes it can't load b) relying on autodiscovery is nice, but broken if you don't control the whole classpath

For "REST Client" I think the solution is trivial (CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE disabled auto detection):

[...]

I have tested it and it works. Thanks a lot!

I checked the "Oracle Cloud Integration" module and it depends on the exported classes to be Jersey 2, this looks like a harder problem.

At least the solution you have posted works for user contributed plugins.

javierllorente avatar Oct 23 '23 21:10 javierllorente

I have created a module for Jersey 3 to avoid conflicts with Jersey 2. It is based on websvc.restlib.

javierllorente avatar Nov 19 '23 21:11 javierllorente

I have updated the PR title and text from the first comment

javierllorente avatar Nov 20 '23 20:11 javierllorente

thanks! all tests were green, removing the label again for subsequent updates.

mbien avatar Nov 21 '23 10:11 mbien