question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jakarta - EE 10 - @Inject should work instead of the deprecated @Context in RESTEasy Classic

See original GitHub issue

Describe the bug

In JAX-RS we used to use @Context to inject several managed objects, including UriInfo:

import jakarta.ws.rs.core.Context;

@Path("/hello")
public class GreetingResource {

    @Context
    UriInfo uriInfo;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        System.out.println("Base URI: " + uriInfo.getBaseUri());
        return "Hello RESTEasy";
    }
}

With Jakarta EE 10 and JAX-RS 4 we can use @Inject instead:

@Inject
UriInfo uriInfo;

ATM, this code breaks with RESTEasy Classic (it works with RESTEasy Reactive) with the following exception:

Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type jakarta.ws.rs.core.UriInfo and qualifiers [@Default]
        - java member: org.acme.GreetingResource#uriInfo
        - declared on CLASS bean [types=[org.acme.GreetingResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.GreeetingResource]
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-reactive</artifactId>
    </dependency>

See https://jakarta.ee/specifications/restful-ws/4.0 Relates to: https://github.com/jakartaee/rest/issues/951

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.0.0.Alpha1

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gsmetcommented, Nov 15, 2022

We should definitely add resteasy-cdi. I will take care of it.

0reactions
agoncalcommented, Nov 14, 2022

Correct, if I have the following 2 dependencies, it works. Will it stay like that or will depending just on quarkus-resteasy be enough in future releases?

  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy</artifactId>
  </dependency>
  <dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-cdi</artifactId>
  </dependency>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jakarta - Add RESTEasy CDI to RESTEasy Common ... - GitHub
Successfully merging this pull request may close these issues. Jakarta - EE 10 - @Inject should work instead of the deprecated @Context in ......
Read more >
RESTEasy - Red Hat on GitHub - JBoss.org
A Jakarta XML Binding Provider is selected by RESTEasy when a parameter or return type is an object that is annotated with Jakarta...
Read more >
Chapter 5. Application Migration Changes
The Java API for XML-based RPC (JAX-RPC) was deprecated in Java EE 6 and was optional in Java EE 7. It is no...
Read more >
Does RESTEasy Reactive work with Javax/Jakarta EE ...
I was looking at the RESTEasy classic to Reactive migration guide and it discuss migrating annotations from org.jboss.resteasy.annotations ...
Read more >
Showing posts for tag "jakartaee" - frostillic.us
In the XPages Jakarta EE project, we use RESTEasy, whose classes are all in the org.jboss.resteasy package space. There's a (usually) hard wall...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found