Keycloak Userstorage SPI: Provider not found? - keycloak

What are the requirments to make the Keycloak 17.0.0 find the provider?
[error]: Build step org.keycloak.quarkus.deployment.KeycloakProcessor#configureProviders threw an exception: java.util.ServiceConfigurationError: org.keycloak.storage.UserStorageProviderFactory: Provider my.own.package.UserStorageProviderFactoryImpl not found
If I clone the project from baeldung and I start the keycloak, it works. It finds the provider. (https://www.baeldung.com/java-keycloak-custom-user-providers)
As I see the followings have to happen to make it work:
have a class that implements the UserStorageProviderFactory interface:
public class UserStorageProviderFactoryImpl implements UserStorageProviderFactory<MyImplementation> {}
create the META-INF and services folders and create the org.keycloak.storage.UserStorageProviderFactory file that contains the path to given factory:
mvn clean package --> copy jar to Keycloak/providers and should work
What do I miss? What is extra in the baeldung project that make it work while my project is not found when I start the keycloak?
https://www.keycloak.org/docs/latest/server_development/index.html#_user-storage-spi

Your class should be name SomethingUserStorageProviderFactory without the word 'impl'. Your provider class should have the same pattern name, for example, SomethingUserStorageProvider.
Official documentation gives more interesting information’s (https://www.keycloak.org/docs/latest/server_development/#_providers) and if you take a look at baeldung's code, he due the same pattern name.

Related

Adding custom jars to camel-k integration

Lets say I have utility jar called validation.jar
which can validate some string to be forwarded.
How can I add this validation.jar along with camel-k integration in minkube.
example :
import com.validation.Util;
import org.apache.camel.builder.RouteBuilder;
public class MyRoute extends RouteBuilder {
#Override
public void configure() throws Exception {
//from("timer:tick").log(Util.validate("dummy message - new"));
from("timer:tick").log("dummy message - new");
}
}
to get com.validation.Util class we need validation.jar available with camel-k. How to provide that.
There is just one way of achieving your goal. Store your java classses with pom.xml file for building jar in github repository. After that you can use Jitpack.io. Jitpack will build and store jar file in its registry. Finally, you can use as dependency on kamel run command.
Starting from camel-k 1.9.x, it is possible to provide a dependency located in the local filesystem by using the file:// prefix when specifying the dependency, like the next example:
kamel run -d file://path/to/validation.jar MyRoute.java

Guice Scala module - No valid constructors

I have playframework application written in scala. Problem is when I want to add new module for Silhouette. My module class is very similar to one from Silhouette example. I can run application trough sbt with simple run command but when I build jar using sbt-assembly and try run it I get:
No valid constructors
at play.api.inject.Modules$.$anonfun$constructModule$6(Module.scala:155)
at scala.Option.getOrElse(Option.scala:138)
at play.api.inject.Modules$.constructModule(Module.scala:155)
at play.api.inject.Modules$.$anonfun$locate$4(Module.scala:127)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237)
at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:321)
at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:977)
at scala.collection.TraversableLike.map(TraversableLike.scala:237)
at scala.collection.TraversableLike.map$(TraversableLike.scala:230)
at scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:51)
at scala.collection.SetLike.map(SetLike.scala:104)
at scala.collection.SetLike.map$(SetLike.scala:104)
at scala.collection.AbstractSet.map(Set.scala:51)
at play.api.inject.Modules$.locate(Module.scala:125)
at play.api.inject.guice.GuiceableModule$.loadModules(GuiceInjectorBuilder.scala:276)
at play.api.inject.guice.GuiceApplicationBuilder$.$anonfun$$lessinit$greater$default$9$1(GuiceApplicationBuilder.scala:30)
at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:102)
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:185)
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:137)
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
at play.core.server.ProdServerStart$.start(ProdServerStart.scala:51)
at play.core.server.ProdServerStart$.main(ProdServerStart.scala:25)
at play.core.server.ProdServerStart.main(ProdServerStart.scala)
I had similar issue and solved it by adding configuration as a parameter to constructor, for some reason it searches for constructor with configuration, not sure if this is the same issue as yours.
import com.typesafe.config.Config;
#Inject
public TradeClearingWorkboardGuiceModule(Environment environment, Config configuration) {
}

How to move Symfony Admin Generator files to a plugin?

I try to move my module which generated by the Admin Genrator to a plugin.
Error:
Fatal error: Class 'BaseFooGeneratorConfiguration' not found in ...
The action.class.php includes to files:
fooGeneratorConfiguration.class.php
fooGeneratorHelper.class.php
Both classes extends of an base class (BaseFooGeneratorConfiguration,BaseFooGeneratorHelper).
The problem is that those classes only exist in the cache.
Do i need to copy the class from cache into my plugin ?!
Have you tried clearing your cache after moving the module to your plugin?
./symfony cc

JAX-WS Deployement error + LocatableWebServiceException: class not found in runtime descriptor

I have deployed JAX-WS web services in Tomcat and when i restarting the tomcat server. I am getting this error on console.
I have putted entry in web.xml and sun-jaxws.xml as per guidelines given in this link -
http://www.jroller.com/eldaaran/entry/using_jax_ws_2_0
Please advise.
SEVERE: WSSERVLET11: failed to parse runtime descriptor: com.sun.xml.ws.util.exception.LocatableWebServiceException: class not found in runtime descriptor: webservices.jaxws.Math
at line 6 of jndi:/localhost/jaxws/WEB-INF/sun-jaxws.xml
com.sun.xml.ws.util.exception.LocatableWebServiceException: class not found in runtime descriptor: webservices.jaxws.Math at line 6 of jndi:/localhost/jaxws/WEB-INF/sun-jaxws.xml
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.getImplementorClass(DeploymentDescriptorParser.java:525)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:201)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:132)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:93)
It looks like the class webservices.jaxws.Math can't be found.
I can't find any reference to this class on the web, so I can only assume that it's a custom class, or the wrong namespace is being used.
Is there a webservices/jaxws/Math.class file?
Do you have a reference to Math in sun-jaxws.xml? I think it is slightly more likely that java.lang.Math is being misnamed than that there is a webservices.jaxws.Math class (I don't see a copy in my version of jax-ws).
webservices.jaxws.Math seems to be your endpoint implementation class. Is this class well packaged and deployed? Are you sure it's in the classpath?

ATG taglibs on OSGI problems

We're currently creating an app that needs ATG taglibs on SLING/OSGI, we have created a bundle with these taglibs and uploaded it, of course these taglibs call ATG classes, so we are including them in the bootdelegation, using sling.properties file.
sling.bootdelegation.simple=atg.nucleus
sling.bootdelegation.class.atg.nucleus.Nucleus=atg.appassembly, \
atg.appassembly.ant, \
atg.appassembly.progress, \
atg.appassembly.util, \
...ETC...
First we got this error:
org.apache.sling.api.scripting.ScriptEvaluationException: atg/taglib/dspjsp/ImportBeanTag
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:163)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:107)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:226)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:465)
....
....
Caused by: java.lang.NoClassDefFoundError: atg/taglib/dspjsp/ImportBeanTag
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspx_meth_dsp_005fimportbean_005f0(center_jsp.java:177)
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspService(center_jsp.java:154)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
So we added atg.taglib.dspjsp to the packages to be added in bootdelegation sling.properties file.
Then we got this error:
org.apache.sling.api.scripting.ScriptEvaluationException: atg.taglib.dspjsp.ImportBeanTag
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:163)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:107)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:226)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:465)
...
Caused by: java.lang.ClassCastException: atg.taglib.dspjsp.ImportBeanTag
at org.apache.sling.scripting.jsp.jasper.runtime.TagHandlerPool.get(TagHandlerPool.java:125)
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspx_meth_dsp_005fimportbean_005f0(center_jsp.java:177)
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspService(center_jsp.java:154)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
All this is running on JBOSS.
Is there a way to avoid this class conflict that is causing the cast exception?
The class cast exception is usually a sign that that class is being made available in two different places (in your case probably via bootdelegation and maybe via a bundle that exports this class). That's what I would investigate first.
Also, to make things more explicit, I would in general advise you to not use boot delegation but instead export these packages explicitly through the system bundle. That way at least you can better debug where classes come from and how things are "wired" by the OSGi resolver.
When loading the ATG tag libraries from outside of the OSGi framework you also have to make sure to provide the JSP API from outside of the framework. By default Sling embeds the JSP API (in the JSP Scripting Bundle).
There are various ways to expose the JSP API into the framework. One is to add them to the system packages in the sling.properties file:
sling.system.packages.atg_jsp = javax.servlet.jsp;javax.servlet.jsp.el; \
javax.servlet.jsp.resources;javax.servlet.jsp.tagext;version=2.1.0