# Stuck at building a provider source code

**URL:** <https://forum.keycloak.org/t/stuck-at-building-a-provider-source-code/24515>\
**Category:** Extending the server\
**Tags:** authentication\
**Created:** [February 12, 2024, 5:28am UTC](https://forum.keycloak.org/t/stuck-at-building-a-provider-source-code/24515 "2024-02-12T05:28:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nefcanto](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/nefcanto/32/3670_2.png) [@Nefcanto](https://forum.keycloak.org/u/Nefcanto)\
**Post date:** [February 12, 2024, 5:28am UTC](https://forum.keycloak.org/t/stuck-at-building-a-provider-source-code/24515/1 "2024-02-12T05:28:47Z")

</div>

A developer wrote us a provider. This provider enables us to log in users using their phone number plus an OTP.

For some reason, he did not support us anymore. Now we want to build it and use it.

The point is that we’re stuck at just building it. We installed JDK 17 on a machine based on what the docs say and used the `./mvnw` at the root of the project. But we can’t build our provider.

We tried to get help from the Keycloak team:

> <https://github.com/keycloak/keycloak/issues/26807>
>
> \### Before reporting an issue
> 
> \- \[X\] I have read and understood the above terms …for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
> 
> \### Area
> 
> dependencies
> 
> \### Describe the bug
> 
> I can't build from the Keycloak source. I want to build the \`authenticator\` provider in the examples directory, but I receive these warnings:
> 
> \> \[WARNING\] 
> \[WARNING\] Some problems were encountered while building the effective model for org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT
> \[WARNING\] 'profiles.profile\[jboss-release\].plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-resources-plugin @ line 355, column 29
> \[WARNING\] 
> \[WARNING\] Some problems were encountered while building the effective model for org.keycloak.testsuite:integration-arquillian-util:jar:999.0.0-SNAPSHOT
> \[WARNING\] 'dependencies.dependency.scope' for org.jboss.arquillian:arquillian-bom:pom must be one of \[provided, compile, runtime, test, system\] but is 'import'. @ line 81, column 20
> \[WARNING\] 
> \[WARNING\] It is highly recommended to fix these problems because they threaten the stability of your build.
> \[WARNING\] 
> \[WARNING\] For this reason, future Maven versions might no longer support building such malformed projects.
> \[WARNING\] 
> 
> 
> And these errors:
> 
> \> \[INFO\] BUILD FAILURE
> \[INFO\] ------------------------------------------------------------------------
> \[INFO\] Total time: 01:27 min
> \[INFO\] Finished at: 2024-02-06T09:38:10+03:30
> \[INFO\] ------------------------------------------------------------------------
> \[ERROR\] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format \<plugin-prefix\>:\<goal\> or \<plugin-group-id\>:\<plugin-artifact-id\>\[:\<plugin-version\>\]:\<goal\>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -\> \[Help 1\]
> \[ERROR\] 
> \[ERROR\] To see the full stack trace of the errors, re-run Maven with the -e switch.
> \[ERROR\] Re-run Maven using the -X switch to enable full debug logging.
> \[ERROR\] 
> \[ERROR\] For more information about the errors and possible solutions, please read the following articles:
> \[ERROR\] \[Help 1\] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
> 
> 
> \### Version
> 
> 23.0.6
> 
> \### Expected behavior
> 
> We should be able to build the examples in the source code out of the box
> 
> \### Actual behavior
> 
> A simple build can not be done
> 
> \### How to Reproduce?
> 
> 1. Clone source
> 2. Install JDK 17 =\> \[docs\](https://github.com/keycloak/keycloak/blob/main/docs/building.md)
> 3. Go to the source, run \`./mvnw\`
> 
> \### Anything else?
> 
> You are a busy team I understand that. But at least give us a hand in using the tool you have written. We do not have a Java developer, yet we are developers and we should be able to at least get a build. I have submitted many issues, questions, and discussions and none gets answered. What should I do?

> <https://github.com/keycloak/keycloak/issues/25049>
>
> \### Before reporting an issue
> 
> \- \[X\] I have read and understood the above terms …for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
> 
> \### Area
> 
> docs
> 
> \### Describe the bug
> 
> Based on \[Getting Started from Docs\](https://www.keycloak.org/getting-started/getting-started-zip) I downloaded OpenJDK 17 and ran Keycloak on my local machine with success.
> 
> Then as we develop inside docker, I created this \`Dockerfile\`:
> 
> \`\`\`
> FROM amd64/debian:bookworm-slim
> 
> RUN apt update -qq \> /dev/null \\
> && apt upgrade -qq \> /dev/null \\
> && apt install openjdk-17-jdk -qq -y \> /dev/null \\
> && apt install openjdk-17-jre -qq -y \> /dev/null \\
> && java -version \\
> && echo 'export JAVA\_HOME=$(dirname $(dirname $(readlink -f $(which java))))' \>\> /etc/bash.bashrc \\
> && echo 'export PATH=$PATH:$JAVA\_HOME/bin' \>\> /etc/bash.bashrc \\
> && mkdir -p /Temp \> /dev/null \\
> && chmod 777 --preserve-root /Temp \> /dev/null \\
> && echo 'public class HelloWorld { public static void main(String\[\] args) { System.out.println("Hello World from Java!"); } }' \> /Temp/Hello.java \\
> && java /Temp/Hello.java \\
> && apt install wget -y \> /dev/null \\
> && wget https://github.com/keycloak/keycloak/releases/download/23.0.0/keycloak-23.0.0.zip --quiet -O /Temp/keycloak.zip \> /dev/null \\
> && apt install unzip -y \> /dev/null \\
> && cd /Temp \\
> && unzip keycloak.zip -d /Keycloak \> /dev/null \\
> && rm -rf keycloak.zip \\
> && cd /Keycloak \> /dev/null \\
> && mv keycloak-23.0.0/\*\* . \> /dev/null \\
> && rm -rf keycloak-23.0.0 \> /dev/null \\
> && ls -lah \\
> && wget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.zip --quiet -O /Temp/maven.zip \> /dev/null \\
> && cd /Temp \\
> && unzip maven.zip -d /usr/share \> /dev/null \\
> && rm -rf maven.zip \\
> && ln -s /usr/share/apache-maven-3.9.5/bin/mvn /usr/bin/mvn \\
> && echo 'M2\_HOME=/usr/share/apache-maven-3.9.5' \>\> /etc/bash.bashrc
> 
> WORKDIR /Keycloak
> \`\`\`
> 
> Basically I used a Debian as the base image, installed JDK and Maven and downloaded Keycloak inside a docker image.
> 
> Then I used this \`docker-compose.yml\` file to run that image:
> 
> \`\`\`
> version: "3.9"
> services:
> accounts:
> image: holism/accounts-dev
> container\_name: AccountsDev
> working\_dir: /Keycloak
> environment:
> - KEYCLOAK\_FRONTEND\_URL=https://dev.accounts.local/
> - PROXY\_ADDRESS\_FORWARDING=true
> - KC\_HOSTNAME=dev.accounts.local
> - KEYCLOAK\_ADMIN=some\_user
> - KEYCLOAK\_ADMIN\_PASSWORD=some\_password
> - KC\_PROXY=edge
> - KC\_HTTP\_ENABLED=true
> - KC\_HOSTNAME\_STRICT=false
> ports:
> - 8080:8080
> command: tail -f /dev/null
> volumes:
> - /Temp/keycloak:/KeycloakSource
> \`\`\`
> 
> Then I went into the container, and into the \`/KeycloakSource/examples/providers/authenticator\` and ran \`mvn clean compile\`.
> 
> I got this error:
> 
> \`\`\`
> root@777fb8f204b2:/KeycloakSource/examples/providers/authenticator# mvn clean compile
> \[INFO\] Loading cache configuration from /KeycloakSource/.mvn/maven-build-cache-config.xml
> \[INFO\] Scanning for projects...
> \[INFO\] 
> \[INFO\] ---------\< org.keycloak:authenticator-required-action-example \>---------
> \[INFO\] Building Authenticator Example 999.0.0-SNAPSHOT
> \[INFO\] from pom.xml
> \[INFO\] --------------------------------\[jar \]---------------------------------
> \[WARNING\] The POM for org.keycloak:keycloak-core:jar:999.0.0-SNAPSHOT is missing, no dependency information available
> \[WARNING\] The POM for org.keycloak:keycloak-server-spi:jar:999.0.0-SNAPSHOT is missing, no dependency information available
> \[WARNING\] The POM for org.keycloak:keycloak-server-spi-private:jar:999.0.0-SNAPSHOT is missing, no dependency information available
> \[WARNING\] The POM for org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT is missing, no dependency information available
> \[INFO\] ------------------------------------------------------------------------
> \[INFO\] BUILD FAILURE
> \[INFO\] ------------------------------------------------------------------------
> \[INFO\] Total time: 0.241 s
> \[INFO\] Finished at: 2023-11-27T13:33:39Z
> \[INFO\] ------------------------------------------------------------------------
> \[ERROR\] Failed to execute goal on project authenticator-required-action-example: Could not resolve dependencies for project org.keycloak:authenticator-required-action-example:jar:999.0.0-SNAPSHOT: The following artifacts could not be resolved: org.keycloak:keycloak-core:jar:999.0.0-SNAPSHOT (absent), org.keycloak:keycloak-server-spi:jar:999.0.0-SNAPSHOT (absent), org.keycloak:keycloak-server-spi-private:jar:999.0.0-SNAPSHOT (absent), org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT (absent): Could not find artifact org.keycloak:keycloak-core:jar:999.0.0-SNAPSHOT -\> \[Help 1\]
> \[ERROR\] 
> \[ERROR\] To see the full stack trace of the errors, re-run Maven with the -e switch.
> \[ERROR\] Re-run Maven using the -X switch to enable full debug logging.
> \[ERROR\] 
> \[ERROR\] For more information about the errors and possible solutions, please read the following articles:
> \[ERROR\] \[Help 1\] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
> \`\`\`
> 
> I'm stuck at this point and I can't solve it. I know it might be a stupid mistake. But I"m not a JAVA developer, I'm a node developer trying to create an OTP provider for Keycloak for my company.
> 
> What should I do? Am I on the right track?
> 
> \### Version
> 
> 23.0.0
> 
> \### Expected behavior
> 
> \`mvn clean compile\` should work for a source code that is inside a java container.
> 
> \### Actual behavior
> 
> It fails and I can't find good resources online.
> 
> \### How to Reproduce?
> 
> \- Build that \`Dockerfile\` above
> \- Rename the image in the \`docker-compose.yml\` accordingly
> \- Clone the source code to \`/Temp\` directory
> \- Run the \`docker-compose.yml\`
> \- Enter the container using \`docker exec -it container\_name bash\`
> \- Go to \`/KeycloakSource/examples/providers/authenticator\`
> \- Run \`mvn clean compile\`
> 
> \### Anything else?
> 
> I know Keycloak is written in Java and developers first need to know how to build Java.
> 
> But since it's a very widespread and valuable tech, and many companies use it without knowing Java, I think it's a good idea if you can create a simple doc on how to prepare Java and Maven and other stuff to develop for Keycloak.
> 
> Thank you.

> **[Why Keycloak team does not develop using the latest JDK version? ·...](https://github.com/keycloak/keycloak/discussions/25026)**
>
> Hi I want to develop OTP for Keycloak and I started from here and it says to download JDK 17. When I go to JDK 17 download page I see this message: In a bold emphasized tone it says: which do not i...

> **[Can't build keycloak provider based on docs · keycloak/keycloak · Discussion...](https://github.com/keycloak/keycloak/discussions/26560)**
>
> Before reporting an issue I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them. Area docs Describe t...

But we got no answer.

So, we had an idea. We wanted to build the example provider that is authored by the Keycloak team:

> <https://github.com/keycloak/keycloak/tree/main/examples/providers/authenticator>
>
> //github.com/keycloak/keycloak/tree/main/examples/providers/authenticator

We managed to create a Dockerfile that builds the entire source code:

```auto
FROM amd64/debian:bookworm-slim

RUN apt update -qq > /dev/null \
    && apt upgrade -qq > /dev/null \
    && apt install openjdk-17-jdk -qq -y > /dev/null \
    && apt install openjdk-17-jre -qq -y > /dev/null \
    && java -version \
    && echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))' >> /etc/bash.bashrc \
    && echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/bash.bashrc \
    && mkdir -p /temp > /dev/null \
    && chmod 777 --preserve-root /temp > /dev/null \
    && echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World from Java!"); } }' > /temp/Hello.java \
    && java /temp/Hello.java \
    && apt install git -y > /dev/null \
    && cd /temp \
    && git clone https://github.com/keycloak/keycloak \
    && cd /temp/keycloak \
    && ./mvnw clean install -DskipTests

WORKDIR /temp/keycloak

```

But it took a long time, and we can’t find the artifacts to use that authenticator.

So, we’re stuck at this point. We want to build a provider source code and use the resulting artifact (or Java package) to extend our Keycloak instance’s capabilities. How can we do that? Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![ThoreKr](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/thorekr/32/7713_2.png) [@ThoreKr](https://forum.keycloak.org/u/ThoreKr)\
**Post date:** [February 12, 2024, 3:46pm UTC](https://forum.keycloak.org/t/stuck-at-building-a-provider-source-code/24515/2 "2024-02-12T15:46:11Z")

</div>

This is probably one of the most convoluted attempts to build something, which makes following your steps and bug reports very tedious.

Skipping all of the needless steps in the dockerfile and compose use, when you build keycloak the final jar is located in examples/providers/authenticator/target/authenticator-required-action-example.jar  
Be aware that these probably won’t work with 23.0.x, as the main branch is already on its way to 24.0.0 and has a lot of incompatible changes.

Just compiling the individual module won’t work because it has in-tree dependencies and compile won’t produce a jar, it just compiles the code.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [February 12, 2024, 3:50pm UTC](https://forum.keycloak.org/t/stuck-at-building-a-provider-source-code/24515/3 "2024-02-12T15:50:09Z")

</div>

This is a cross-post of this Slack thread:

> **[Slack is your productivity platform](https://cloud-native.slack.com/?redir=%2Farchives%2FC056XU905S6%2Fp1707713445096719%3Fname%3DC056XU905S6%26perma%3D1707713445096719)**
>
> Slack is a new way to communicate with your team. It’s faster, better organized, and more secure than email.

---

<div class="post-metadata">

**Author:** ![ThoreKr](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/thorekr/32/7713_2.png) [@ThoreKr](https://forum.keycloak.org/u/ThoreKr)\
**Post date:** [February 12, 2024, 4:10pm UTC](https://forum.keycloak.org/t/stuck-at-building-a-provider-source-code/24515/4 "2024-02-12T16:10:40Z")

</div>

Thank you for the warning
