quarkus: ContextNotActiveException: SessionScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean

Describe the bug

I have code like the below:

@ApplicationScoped
@Path("/")
public class Application {

    @Inject
    SessionScopedCalciteSchema sessionScopedCalciteSchema;

    @CheckedTemplate(requireTypeSafeExpressions = false)
    static class Templates {
        public static native TemplateInstance index(SchemaPlus rootSchema);
    }

    @GET
    public TemplateInstance index() {
        SchemaPlus rootSchema = sessionScopedCalciteSchema.getCalciteConnection().getRootSchema();
        return Templates.index(rootSchema);
    }
}
@SessionScoped
public class SessionScopedCalciteSchema implements java.io.Serializable {

    private UUID id;
    private DataSource h2DataSource;
    private CalciteConnection calciteConnection;

    public SessionScopedCalciteSchema() {
    }

    @PostConstruct
    void init() {
        this.id = UUID.randomUUID();
        this.h2DataSource = ChinookDatabaseService.createChinookDatabase(id.toString());
        this.calciteConnection = initCalciteConnection();

        SchemaPlus rootSchema = calciteConnection.getRootSchema();
        JdbcCatalogSchema catalog = JdbcCatalogSchema.create(rootSchema, "chinook", h2DataSource, null);
        rootSchema.add("chinook", catalog);
    }

    private static CalciteConnection initCalciteConnection() {
      // ...
    }

    // getters/setters
}

Running it throws this error:

javax.enterprise.context.ContextNotActiveException: SessionScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=io.github.gavinray97.service.SessionScopedCalciteSchema, id=5ceb6548b8253f07699efa8b7c65908ba6b0a510]
	at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:53)
	at io.github.gavinray97.service.SessionScopedCalciteSchema_ClientProxy.arc$delegate(Unknown Source)
	at io.github.gavinray97.service.SessionScopedCalciteSchema_ClientProxy.getCalciteConnection(Unknown Source)
	at io.github.gavinray97.Application.index(Application.java:30)
	at io.github.gavinray97.Application_Subclass.index$$superforward1(Unknown Source)
	at io.github.gavinray97.Application_Subclass$$function$$7.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)

My dependencies are:

implementation("io.quarkus:quarkus-arc")
implementation("io.quarkus:quarkus-jdbc-h2")
implementation("io.quarkus:quarkus-resteasy-reactive-jackson")
implementation("io.quarkus:quarkus-resteasy-reactive-qute")
implementation("io.quarkus:quarkus-resteasy-reactive")
implementation("io.quarkus:quarkus-undertow")

Using version 2.11.1.Final

What does this error mean? 🤔

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

No response

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

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (17 by maintainers)

Most upvoted comments

Maybe it could be good to put a little note at the top of the RESTEasy Reactive extension saying “Hey, these are the JAX-RS annotations which you may expect to be present/work but which don’t currently exist in the Reactive variant” FWIW too

I was actually thinking that we should fail the build if a @SessionScoped bean is injected into a JAX-RS resource (when RESTEasy Reactive is being used).

WDYT @mkouba ?

Yup

On Tue, Jan 17, 2023, 16:27 Gavin Ray @.***> wrote:

@GavinRay97 https://github.com/GavinRay97 Sure I can make the PR for the extensions docs 👍

Is it only for SessionScoped that is not available at the moment?

— Reply to this email directly, view it on GitHub https://github.com/quarkusio/quarkus/issues/27237#issuecomment-1385509831, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBMDP5QTEGZSSZSCM72LNDWS2T4FANCNFSM56GD7HUA . You are receiving this because you modified the open/close state.Message ID: @.***>

@GavinRay97 Sure I can make the PR for the extensions docs 👍

Is it only for SessionScoped that is not available at the moment?