0
votes

I have a Quarkus app that uses cdi and resteasy. I have a bean that is annotated as SessionScoped

import javax.enterprise.context.SessionScoped;
@SessionScoped
public class SessionScopedBean implements Serializable {}

When I inject this bean into my web resource I get javax.enterprise.inject.UnsatisfiedResolutionException:

@Path("/dep")
public class DependencyResource {

    private final SessionScopedBean ses;

    public DependencyResource(SessionScopedBean ses) {
        this.ses = ses;
    }
}

Stack trace:

Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: 
Unsatisfied dependency for type SessionScopedBean and qualifiers [@Default]
        - java member: DependencyResource#<init>()
        - declared on CLASS bean [types=[DependencyResource], qualifiers=[@Default, @Any], target=DependencyResource]
        at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:472)
        at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)

If I change it to ApplicationScoped or RequestScoped it works without any other changes.

Do SessionScoped beans work with Quarkus 1.0.0.CR1?

1
Do you have the right sessionscoped annotation?Kukeltje
I'm using import javax.enterprise.context.SessionScoped;Sean
try injecting the service as: @Inject SessionScopedBean sesHector Ventura Reyes
@HectorVenturaReyes yes, I have tried it that way too. Same result.Sean
I suspect things may have been updated since 2019-10-13 relevant docs at quarkus.io/guides/cdi-reference and I just created a @SessionScoped bean without undertowNigel Savage

1 Answers

3
votes

In Quarkus, there is SessionContext but it is wired directly into Undertow extension as opposed to request or application contexts which are part of Arc (Quarkus DI) that you get almost always as components require it.

Therefore, check that you have undertow extension enabled or try adding it manually and see it that helps.