我尝试在我的keycloak项目中创建一个自定义spi,遵循基本的keycloack结构,我添加了自定义提供程序接口,该接口扩展了提供程序,自定义提供程序工厂并按照keycloak文档中的说明为它们实现自定义spi,并且它们在源代码,之后,我为提供者和提供者工厂创建了一个自定义实现,如文档所述,我在META-INF / services中创建了文件,并且像在比拉斗篷示例中一样,我正在使用耳式部署,但是当我尝试使用时我的代码空指针异常中的提供程序被抛出,仅当我尝试添加自定义spi时才会发生,如果我实现的提供程序具有现有的keycloak spi,则它可以工作,如果我正在使用模块方法,则该方法也可以工作一个带有jboss-cli的新模块,但是这种方法似乎很难维护,任何人都知道为什么会发生这种情况以及如何解决它,或者什么是最好的方法,谢谢。
08:43:48,264警告[org.keycloak.services](默认任务1)KC-SERVICES0013:身份验证失败:java.lang.NullPointerException 在sso.authentication.forms.RegistrationProfile.validate(RegistrationProfile.java:55) 在org.keycloak.authentication.FormAuthenticationFlow.processAction(FormAuthenticationFlow.java:214) 在org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:99) 在org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:873) 在org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:296) 在org.keycloak.services.resources.LoginActionsService.processRegistration(LoginActionsService.java:631) 在org.keycloak.services.resources.LoginActionsService.registerRequest(LoginActionsService.java:685) 在org.keycloak.services.resources.LoginActionsService.processRegister(LoginActionsService.java:665) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498) 在org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138) 在org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:517) 在org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:406) 在org.jboss.resteasy.core.ResourceMethodInvoker.lambda $ invokeOnTarget $ 0(ResourceMethodInvoker.java:370) 在org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:355) 在org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:372) 在org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:344) 在org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:137) 在org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:100) 在org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440) 在org.jboss.resteasy.core.SynchronousDispatcher.lambda $ invoke $ 4(SynchronousDispatcher.java:229) 在org.jboss.resteasy.core.SynchronousDispatcher.lambda $ preprocess $ 0(SynchronousDispatcher.java:135) 在org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:355) 在org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:138) 在org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:215) 在org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:227) 在org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) 在org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:791) 在io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) 在io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:129) 在org.keycloak.services.filters.KeycloakSessionServletFilter.doFilter(KeycloakSessionServletFilter.java:90) 在io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) 在io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter(FilterHandler.java:131) 在io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) 在io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 在io.undertow.servlet.handlers.ServletChain $ 1.handleRequest(ServletChain.java:68) 在io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 在org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)处 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) 在io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 在io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 在io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 在io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) 在io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 在io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)处 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68) 在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 在io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) 在io.undertow.servlet.handlers.ServletInitialHandler.access $ 100(ServletInitialHandler.java:81) 在io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:138) 在io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:135) 在io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java:48) 在io.undertow.servlet.core.ContextClassLoaderSetupAction $ 1.call(ContextClassLoaderSetupAction.java:43) 在org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda $ create $ 0(SecurityContextThreadSetupAction.java:105) 在org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1502) 在org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1502) 在org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1502) 在org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1502) 在io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) 在io.undertow.servlet.handlers.ServletInitialHandler.access $ 000(ServletInitialHandler.java:81) 在io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(ServletInitialHandler.java:104) 在io.undertow.server.Connectors.executeRootHandler(Connectors.java:364) 在io.undertow.server.HttpServerExchange $ 1.run(HttpServerExchange.java:830) 在org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) 在org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982) 在org.jboss.threads.EnhancedQueueExecutor $ ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) 在org.jboss.threads.EnhancedQueueExecutor $ ThreadBody.run(EnhancedQueueExecutor.java:1377) 在java.lang.Thread.run(Thread.java:748)
答案 0 :(得分:0)
如果您仔细查看$JBOSS_HOME/standalone/configuration/standalon-ha.xml
或$JBOSS_HOME/standalone/configuration/standalon.xml
文件,则会在以下位置看到这些行:
<providers>
<provider>classpath:${jboss.home.dir}/providers/*</provider>
</providers>
这意味着,必须先将编译后的文件保存在根${jboss.home.dir}/providers/
的文件夹中,然后才能注册SPI
。
执行此操作基本上与在其中添加模块路径的新行相同,例如
<providers>
<provider>classpath:${jboss.home.dir}/providers/*</provider>
<provider>module:com/selast/keycloak-provider/*</provider>
</providers>
希望它对您有所帮助,因为我已经花了一天时间?。