-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Hibernate Multitenant project with a @RequestScoped TenantResolver throws javax.enterprise.context.ContextNotActiveException #19467
Comments
+1 same here |
also i noticed that in v 2.1.x quarkus raise a warning but the application work.
|
@stefanorg how do I reproduce the error you mentioned in #19467 (comment)? Can you provide a sample app? |
@stefanorg I created #19593 and provided a potential fix, can you test and let me know if that works for you? |
ok @gastaldi, thank you. I'll build the PR and let you know. |
@gastaldi i confirm that your PR fixes the NPE.
|
@stefanorg thanks for testing it! Can you share your |
@stefanorg no need to share it, I can reproduce this issue with the following TenantResolver: @RequestScoped
public class MyTenantResolver implements TenantResolver {
@Override
public String getDefaultTenantId() {
return "Tenant";
}
@Override
public String resolveTenantId() {
return "Abc";
}
} And this is my application.properties: quarkus.hibernate-orm.database.generation=create
quarkus.hibernate-orm.multitenant=DATABASE |
Sorry for late response, yes nothing fancy on my side, only request scoped resolver with custom tenant resolver logic that depends on static configuration. |
@stefanorg can you build #19618 and let me know if that works for you? |
@gastaldi to me seems ok, no more warnings 👍 |
Describe the bug
I'm using the
SCHEMA
hibernate multitenant option, implementing aTenantResolver
that is@RequestScoped
so that I can use an@Inject
edJsonWebToken
At startup, the app logs a warning when trying to call the
getDefaultTenantId
method to get the connection metadata ( see below ). This happens in 2.1., and didn't happen in 1.1., so it seems a regression.More severe is that if I use the hibernate migrations(*), the app won't start as it can't get the default tenant. The error stack is similar but it's triggered from the migration classes. See the attached multitenant-2.1.2-migrate.zip file
(*) I know that https://quarkus.io/guides/hibernate-orm#configuring-the-application doesn't recommend using the hibernate generation with a multitenant config, but it's useful for a dev or test setup where I run just one schema.
To avoid this warning/error, as a workaround I have to use an
@ApplicationScoped
TenantResolver and then get the JsonWebToken "manually" using:Here's the full stack trace:
Expected behavior
No warnings, TenantResolver created and
getDefaultTenantId
calledActual behavior
See stack trace above
How to Reproduce?
I'm adding a mvn project to reproduce the error. Run
./mvnw compile quarkus:dev
multitenant-2.1.2.zip
Compare with the 1.1.7 version which runs ok ( this needs a pg db running )
1.1.7.zip
Output of
uname -a
orver
Darwin MBP-15-Ramiro.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64
Output of
java -version
openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
GraalVM version (if different from Java)
not used
Quarkus version or git rev
2.1.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/ramiro/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.11, vendor: AdoptOpenJDK, runtime: /Users/ramiro/.sdkman/candidates/java/11.0.11.hs-adpt Default locale: en_AR, platform encoding: UTF-8 OS name: "mac os x", version: "11.3", arch: "x86_64", family: "mac"
Additional information
No response
The text was updated successfully, but these errors were encountered: