-
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
Unable to read RoutingContext from CustomTenantResolver #44168
Comments
My assumption is that what's going on here is that there is no active web request, but I'll leave it to the SMEs. @yrodiere and @sberyozkin |
It's not working on both, runtime and on request I am running this code on Quarkus 3.0 and unfortunately, I am unable to upgrade to the latest version as I am using Optaplanner |
This version is very old and it completely unsupported at this point.
Optaplanner does not work with newer versions of Quarkus? |
when I upgrade to quarkus 3.15.1 I get this error, also I am running the latest version of Optaplanner 9.44 here's the error 2024-10-30 16:40:17,515 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.NoClassDefFoundError: io/quarkus/devconsole/spi/DevConsoleRouteBuildItem
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at io.quarkus.deployment.util.ServiceUtil.classesNamedIn(ServiceUtil.java:30)
at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:165)
at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:107)
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:350)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:272)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:62)
at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:91)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:430)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:57)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: java.lang.ClassNotFoundException: io.quarkus.devconsole.spi.DevConsoleRouteBuildItem
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:533)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:481)
... 15 more |
And there is no newer version of Optaplanner? |
I have the latest version of Optaplanner, it's 9.44
|
In that case you should probably consider Timefold |
Unfortunately, I am unable to move to different engines, as I am in the last phase of the project |
Even if this were a bug and we fixed it, there is absolutely no chance of backporting the change to anything before 3.15 |
I fixed dependency issues, and upgraded to 3.15.1 and I still get the same error
|
Great you were able to upgrade! Any chance you can put a small sample project together that makes it trivial for us to reproduce the problem? |
#44168 (comment) stacktrace shows that you are requesting |
It was tested on startup and on request and the request was null I found git repo and worked with me, |
I can run linked project in next weeks, but I cannot run it ATM (busy). Maybe someone will have time sooner. If you want quick tips, I suggest following:
Just from reading your code I am not sure when |
@amustafa91 the only way we can meaningfully help is if you attach a sample project that exhibits the problematic behavior and provide trivial steps to do so. Currently, all indications point to the fact that there is no active HTTP request |
Thank you for this. @PersistenceUnitExtension
@RequestScoped
public class CustomTenantResolver implements TenantResolver {
@Inject
CurrentVertxRequest vertxRequest;
@Override
public String getDefaultTenantId() {
Log.info("getDefaultTenantId returning default");
return "default";
}
@Override
public String resolveTenantId() {
String defaultTenantId = getDefaultTenantId();
if (vertxRequest == null || vertxRequest.getCurrent() == null) {
return defaultTenantId;
}
// CustomTenantConfigResolver has already calculated the tenant id and saved it as a RoutingContext `tenantId` attribute:
return vertxRequest.getCurrent().get("tenantId", defaultTenantId);
}
} |
@amustafa91, Tom from the Timefold team here. Just FYI, moving from Timefold to Optaplanner can be done by running an OpenRewrite script. Timefold is a fork of OptaPlanner so you don't have to change much. We are compatible with the latest versions of Quarkus. See: https://docs.timefold.ai/timefold-solver/latest/upgrading-timefold-solver/upgrade-from-optaplanner |
@michalvavrik @yrodiere I don't think there's anything to fix here but maybe we could find a place to document this? |
I have checked same situation that is tested in security JPA |
Describe the bug
I am trying to read the tenant from RoutingContext, to resolve the database connection based on tenantId, but getting this error
Expected behavior
Read RoutingContext keys from CustomTenantResolver
Actual behavior
Getting jakarta.enterprise.inject.IllegalProductException: Normal scoped producer method may not return null: io.quarkus.vertx.http.runtime.CurrentVertxRequest.getCurrent()
How to Reproduce?
Setting the tenant Id in my OIDC resolver
My database connection resolver
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
I tried every solution on Internet with no luck
The text was updated successfully, but these errors were encountered: