kc build command fail from source in development mode

See original GitHub issue

Describe the bug

I am going to add custom providers in Keycloak 19.0.1. I put the jar file into /quarkus/dist/src/main/content/providers folder By following the README, I need to build from kc.sh

When I exec the mvn command from IDE, the build fail

# in keycloak/quarkus folder
$ mvn -f server/pom.xml compile quarkus:dev -Dquarkus.args="--verbose build"

The error log is

Updating the configuration and installing your custom providers, if any. Please wait.
ERROR: Failed to run 'build' command.
Error details:
java.nio.file.NoSuchFileException: /Users/clixin/.m2/repository/io/quarkus/lib/deployment/deployment-class-path.dat
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:375)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:426)
        at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
        at java.base/java.nio.file.Files.newInputStream(Files.java:160)
        at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doReaugment(QuarkusEntryPoint.java:71)
        at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:47)
        at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:31)
        at org.keycloak.quarkus.runtime.cli.command.Build.run(Build.java:71)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at org.keycloak.quarkus.runtime.cli.Picocli.parseAndRun(Picocli.java:91)
        at org.keycloak.quarkus.runtime.KeycloakMain.main(KeycloakMain.java:89)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
        at java.base/java.lang.Thread.run(Thread.java:832)

Version

19.0.1

Expected behavior

Build success

Actual behavior

Build failed with stack trace.

How to Reproduce?

  1. cd quarkus
  2. $ mvn -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests
  3. $ mvn clean install -DskipTests
  4. $ mvn -f server/pom.xml compile quarkus:dev -Dquarkus.args="--verbose build"

Anything else?

I have some investigation and found that

  1. The not found file deployment-class-path.dat is in the quarkus/server/target folder after I build in IDE successfully.
  2. And the way QuarkusEntryPoint to locate the file is from this source code. It resolves to my local maven repository which is /Users/clixin/.m2/repository/io/quarkus/

https://github.com/quarkusio/quarkus/blob/354b536774631a64b9c21e3c4bccb1269bb2a601/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/QuarkusEntryPoint.java#L38-L48

QuarkusEntryPoint.class.getProtectionDomain().getCodeSource().getLocation().getPath();

My current workaround is shadowing the QuarkusEntryPoint class and then specify the correct path.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pedroigorcommented, Aug 3, 2022

@lexcao You don’t actually need to run a build when in dev mode because the augmentation steps (the build steps run by quarkus) are always run.

That said, you should be able to just call start or start-dev.

The steps you see in that README file are when running the distribution.

if you really want to try out Quarkus dev mode to implement your provider, you can just implement your providers within the server module. See https://github.com/keycloak/keycloak/tree/main/quarkus/server. Any file you put there is automatically reloaded and quarkus:dev should work fine.

Another approach is to create your own project similar to our server module. And use it just like a “regular” Quarkus application. In this case, you don’t even need to clone our repository.

Note that I really appreciate what you are trying to achieve and we want to improve the developer experience to make it easier and fun to develop extensions to Keycloak. Perhaps while it does not happen, we can at least provide some blog or documentation about it.

You might also considering looking at this work from @thomasdarimont. You might not want to build your own distribution but it is related to the second approach above.

1reaction
lexcaocommented, Aug 3, 2022

if you really want to try out Quarkus dev mode to implement your provider, you can just implement your providers within the server module

This method works fine for me, by adding my custom provider dependency to the server pom.xml. And it loads the provider as expected and gives me fast feedback.

Thank you again! @pedroigor

Read more comments on GitHub >

github_iconTop Results From Across the Web

bin/kc.sh start-dev fails with banner issue #10954 - GitHub
I downloaded keycloak 17.0.1 tar.gz and ran kc.sh start-dev. It failed with the following error: ERROR: Failed to run 'build' command.
Read more >
Configuring Keycloak
Configuration sources have a descending ordinal: command-line parameters take ... The production mode is started by invoking the following command: bin/kc.
Read more >
Getting Error While Fetching Keycloak Image Via Docker
I am trying to start keycloak image using docker .yml file on local with PostgreSQL database but getting error. .yml file:- version: '3'....
Read more >
Configuration command optional in Keycloak.X - Google Groups
Hi,. When configuring the server, users must run the `config` command when changing any build/static property [1] such as those related to the ......
Read more >
Troubleshooting : WebSphere start/stop common issues - IBM
Try running the “java –fullversion” command from the WAS_HOME/java/jre/bin directory. If this command fails, then Java likely has a problem.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found