[keycloak-dev] Deploying provider with dependencies
Mark Pardijs
mark.pardijs at topicus.nl
Mon Mar 20 04:43:19 EDT 2017
@Bill Burke, any thoughts on this? Thought I might bump this since it’s a reply on an old thread so maybe it’s not noticed.
Op 15 mrt. 2017, om 16:16 heeft Mark Pardijs <mark.pardijs at topicus.nl<mailto:mark.pardijs at topicus.nl>> het volgende geschreven:
I somehow sort of solved this, but still am curious if this is the way to go.
The way I understand it now is: the providers dir is a non-hot deploy method which uses the same classpath as keycloak.
The deployments dir is the hot-deployment method where you have to provide the libs on classpath or depend on them via modules.
The way I configured it now is the following:
- The maven jar plugin which builds a manifest file [1]. When I package my third party libs in the ear I get ClassNotFound errors, so I have to depend on modules defined already in keycloak
- The maven ear plugin which also builds the proper application.xml [2]
Is this the way to go?
[1]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifestEntries>
<Dependencies>org.keycloak.keycloak-server-spi-private,org.keycloak.keycloak-services,org.apache.commons.lang</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
[2]
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<!--<defaultLibBundleDir>lib</defaultLibBundleDir>-->
<modules>
<jarModule>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<jarModule>
<groupId>myGroupId2</groupId>
<artifactId>myArtifactId2</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
</modules>
</configuration>
</plugin>
Op 14 mrt. 2017, om 18:21 heeft Mark Pardijs <mark.pardijs at topicus.nl<mailto:mark.pardijs at topicus.nl><mailto:mark.pardijs at topicus.nl>> het volgende geschreven:
I’m trying to add a custom authenticator to Keycloak, and I’m also confused on this topic.
First, I copied my jar in the keycloak/providers directory, this works.
Then, I started to depend on a third party library, so I needed to add this third party jar in my providers directory. Since it’s not very convenient to copy all third party libs I tried some other ways but I’m lost now.
I could build an ear file with my my custom jar and third party libs in it, and place it in the deployments directory, but then the service module loader fails with the following message:
17:13:31,485 WARN [org.jboss.modules] (ServerService Thread Pool -- 50) Failed to define class nl.MyAuthenticatorFactory in Module "deployment.keycloak-authenticator-ear-1.0-SNAPSHOT.ear.keycloak-authenticat-1.0-SNAPSHOT.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link nl/MyAuthenticatorFactory (Module "deployment.keycloak-authenticator-ear-1.0-SNAPSHOT.ear.keycloak-authenticator-1.0-SNAPSHOT.jar:main" from Service Module Loader): org/keycloak/authentication/AuthenticatorFactory.
When I put the ear in the providers dir, it’s not picked up at all.
I think I’m missing something in my ear file, I read something about a jboss-deployment-structure.xml but can’t find a good example of using this in this situation.
So, hopefully you can help me with these quesitons:
1. Isn’t it possible to depend on a third party lib that’s already on the keycloak’s default classpath? I’m depending on commons-lang lib, thought which is also in keycloak’s default classpath, but still when using my provider I get a ClassNotFound error
2. The documentation is mentioning two ways to deploy a provider: using the /providers dir or using the deployments dir, which one is recommended when?
3. What’s the expected structure of an ear file for use in the deployments directory? Currently I have the same as Dmitry mentioned below
Op 22 jan. 2017, om 23:16 heeft Dmitry Telegin <mitya at cargosoft.ru<mailto:mitya at cargosoft.ru><mailto:mitya at cargosoft.ru><mailto:mitya at cargosoft.ru>> het volgende geschreven:
Tried with 2.5.0.Final - the EAR doesn't get recursed unless there's an
application.xml with all the internal JARs explicitly declared as
modules. Could it have been some special jboss-deployment-structure.xml
in your case?
Either way, it's a very subtle issue that deserves being documented
IMHO.
Cheers,
Dmitry
В Thu, 19/01/2017 в 09:56 -0500, Bill Burke пишет:
I'm pretty sure you can just remove the application.xml too. Then
the
ear will be recursed. I tried this out when I first wrote the
deployer.
On 1/18/17 4:20 PM, Dmitry Telegin wrote:
I've finally solved this. There are two moments to pay attention
to:
- maven-ear-plugin by default generates almost empty
application.xml.
In order for subdeployment to be recognized, it must be mentioned
in
application.xml as a module. Both <ejb> and <java> worked for me;
- in JBoss/WildFly, only top-level jboss-deployment-structure.xml
files
are recognized. Thus, this file should be moved from a JAR to an
EAR
and tweaked accordingly. This is discussed in detail here:
http://stackoverflow.com/questions/26859092/jboss-deployment-struct
ure-
xml-does-not-loads-the-dependencies-in-my-ear-project
Again, it would be nice to have a complete working example to
demonstrate this approach. I think I could (one day) update my
BeerCloak example to cover this new deployment technique.
Dmitry
В Wed, 18/01/2017 в 23:10 +0300, Dmitry Telegin пишет:
Stian,
I've tried to package my provider JAR into an EAR, but that
didn't
work
:(
The layout is the following:
foo-0.1-SNAPSHOT.ear
+- foo-provider-0.1-SNAPSHOT.jar
+- META-INF
+- application.xml
When I put the JAR into the deployments subdir, it is deployed
successfully, initialization code is called etc. But when I drop
the
EAR in the same subdir, there is only a successful deployment
message.
The provider doesn't get initialized; seems like deployer doesn't
recurse into EAR contents. Tried to place the JAR into the "lib"
subdir
inside EAR, this didn't work either. The EAR is generated by
maven-
ear-
plugin with the standard settings.
Am I missing something? Sorry for bugging you, but unfortunately
there
is not much said in the docs about deploying providers from
inside
EARs. A working example would be helpful as well.
Dmitry
В Wed, 18/01/2017 в 12:34 +0100, Stian Thorgersen пишет:
You have two options deploy as a module which requires adding
modules
for all dependencies or using the new deploy as a JEE archive
approach, which also supports hot deployment. Check out the
server
developer guide for more details.
On 18 January 2017 at 11:54, Dmitry Telegin <mitya at cargosoft.ru<mailto:mitya at cargosoft.ru><mailto:mitya at cargosoft.ru>
wrote:
Hi,
It's easy to imagine a provider that would integrate a third
party
library which, together with transitive dependencies, might
result
in
dozens of JARs. A real-world example: OpenID 2.0 login
protocol
implementation using openid4java, which in its turn pulls in
another 10
JARs.
What are the deployment options for configurations like that?
Is
it
really necessary to install each and every dependency as a
WildFly
module? This could become a PITA if there are a lot of deps.
Could
it
be a single, self-sufficient artifact just to be put into
deployments
subdir? If yes, what type of artifact it should be (EAR
maybe)?
Thx,
Dmitry
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org><mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org<mailto:keycloak-dev at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-dev
More information about the keycloak-dev
mailing list