我试图在我Java的web应用程序中实例化一个org.keycloak.admin.client.KeyCloak
对象,该应用程序使用QUUKUS作为其应用程序框架。我过去在已经部署到Wildfly的应用程序上成功地做到了这一点,但是它并没有像预期的那样转换到QUARKUS。我的实例化KeyCloak
对象的工厂类如下所示:
Keycloak kc = KeycloakBuilder.builder().serverUrl(authServerURL).realm(realmName).clientId(clientID)
.clientSecret(clientSecret).username(adminUsername).password(adminPassword).build();
但是,当我尝试调用factory方法时,最终出现以下异常:
14:10:08 ERROR [io.undertow.request.io] Exception handling request 87ecb4cf-b4b3-4e2b-9e54-7427c88f9897-1 to /api/v1/tests/accounts/create: java.lang.InstantiationError: org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
at org.keycloak.admin.client.Keycloak.newRestEasyClient(Keycloak.java:70)
at org.keycloak.admin.client.Keycloak.<init>(Keycloak.java:57)
at org.keycloak.admin.client.KeycloakBuilder.build(KeycloakBuilder.java:147)
at com.myapp.test.security.keycloak.KeycloakClientFactory.createKeycloakClient(KeycloakClientFactory.java:75)
at com.myapp.test.security.keycloak.KeycloakAdminClient.init(KeycloakAdminClient.java:58)
at com.myapp.test.security.keycloak.KeycloakAdminClient_Bean.create(KeycloakAdminClient_Bean.zig:80)
at com.myapp.test.security.keycloak.KeycloakAdminClient_Bean.get(KeycloakAdminClient_Bean.zig:202)
at com.myapp.test.security.keycloak.KeycloakAdminClient_Bean.get(KeycloakAdminClient_Bean.zig:61)
at com.myapp.test.rest.services.test.TestRS_Bean.create(TestRS_Bean.zig:320)
at com.myapp.test.rest.services.test.TestRS_Bean.create(TestRS_Bean.zig:179)
at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:80)
at io.quarkus.arc.impl.ComputingCache$CacheFunction.lambda$apply$0(ComputingCache.java:99)
at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:41)
at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:25)
at com.myapp.test.rest.services.test.TestRS_Bean.get(TestRS_Bean.zig:163)
at com.myapp.test.rest.services.test.TestRS_Bean.get(TestRS_Bean.zig:405)
at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:355)
at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:367)
at io.quarkus.arc.impl.ArcContainerImpl$1.get(ArcContainerImpl.java:222)
at io.quarkus.arc.impl.ArcContainerImpl$1.get(ArcContainerImpl.java:219)
at io.quarkus.arc.runtime.ArcRecorder$2$1.create(ArcRecorder.java:79)
at io.quarkus.resteasy.common.runtime.QuarkusConstructorInjector.construct(QuarkusConstructorInjector.java:56)
at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:69)
at org.jboss.resteasy.core.ResourceLocatorInvoker.createResource(ResourceLocatorInvoker.java:62)
at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:112)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:60)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:270)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:59)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:116)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:113)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1$1.call(UndertowDeploymentRecorder.java:475)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:250)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:59)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:82)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:290)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:669)
at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:224)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1395)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at java.base/java.lang.Thread.run(Thread.java:830)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
14:10:08 DEBUG [io.undertow.request.error-response] Setting error code 500 for exchange HttpServerExchange{ GET /api/v1/tests/accounts/create delegate io.undertow.vertx.VertxHttpExchange@2bcf472c}: java.lang.RuntimeException
at io.undertow.server.HttpServerExchange.setStatusCode(HttpServerExchange.java:1108)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:295)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:59)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:116)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:113)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1$1.call(UndertowDeploymentRecorder.java:475)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:250)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:59)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:82)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:290)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:669)
at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:224)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1395)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at java.base/java.lang.Thread.run(Thread.java:830)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
我的假设是,这与RestEasy版本不匹配或其他依赖关系问题有关。然而,我不知道如何解决这个问题。有什么建议吗?
更新1:现在包含完整的堆栈跟踪
似乎已在Quarkus 1.4(发行说明)中修复。
该版本添加了一个新的扩展quarkus KeyClope管理客户端
(源代码)。
我试图在一个Spring引导应用程序中使用keyCloak管理客户端来改变keyCloak中用户的角色,但是我甚至不能实例化keyCloak。 我正在尝试在这里获取KeyClope服务器,但是我得到了一个实例化错误
我以前在其他项目中实现过类似的功能,但从未使用Quarkus作为底层实现框架。所以,我的猜测是与此有关。但我从没见过这样的错误。有人能给我一些关于如何绕过这个问题的见解吗?
我喜欢从我自己的应用程序管理键斗篷:创建用户 请求一个访问令牌,其用户名:密码在标题 但答案是403: 如何/是否可能通过客户端凭据授权从新服务帐户访问Admin REST API?
我已经开始用MongoDB客户端探索Quarkus。我在文档中遇到了很多锅炉板代码。(特别是。BSON) 参考: https://quarkus.io/guides/mongo-guide 我们不能利用注释来生成代码吗?这是有意避免反射开销吗?
The AdminClient API supports managing and inspecting topics, brokers, acls, and other Kafka objects. To use the AdminClient API, add the following Maven dependency: <dependency> <groupId>org.apac
在我的quarkus rest项目中,我有一个使用mutiny的restclient: 我想处理Property non 2XX httpError,所以我制作了我的例外文件 客户端上的错误调用显示MyExceptionMapper处理响应,但异常会引发,并且不会成为我的Uni客户端响应对象上的失败 我是否以错误的方式对rest客户使用叛变? 谢谢 更新 好吧,我忘了添加依赖quarkus res