Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Jersey 3 module #6582

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

javierllorente
Copy link

@javierllorente javierllorente commented Oct 17, 2023

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.

@pepness
Copy link
Member

pepness commented Oct 17, 2023

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

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Java EE/Jakarta EE [ci] enable enterprise job Upgrade Library Library (Dependency) Upgrade ci:all-tests [ci] enable all tests and removed Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) labels Oct 18, 2023
@mbien
Copy link
Member

mbien commented Oct 18, 2023

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

@javierllorente
Copy link
Author

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
Copy link
Author

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.

@pepness
Copy link
Member

pepness commented Oct 18, 2023

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.

@matthiasblaesing
Copy link
Contributor

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.

@javierllorente
Copy link
Author

javierllorente commented Oct 23, 2023

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
Copy link
Author

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
Copy link
Author

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

Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I unlocked CI to check if its happy with the new module. Please update PR title and text to reflect the changed goal of this PR.

enterprise/jersey3/arch.xml Show resolved Hide resolved
@javierllorente javierllorente changed the title Upgrade to Jersey 3 New Jersey 3 module Nov 20, 2023
@javierllorente
Copy link
Author

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

@mbien mbien added this to the NB21 milestone Nov 21, 2023
@mbien mbien removed the ci:all-tests [ci] enable all tests label Nov 21, 2023
@mbien
Copy link
Member

mbien commented Nov 21, 2023

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

@neilcsmith-net neilcsmith-net modified the milestones: NB21, NB22 Jan 16, 2024
@ebarboni ebarboni modified the milestones: NB22, NB23 Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java EE/Jakarta EE [ci] enable enterprise job Upgrade Library Library (Dependency) Upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants