[keycloak-dev] How to setup a maven project generating jar containing authentication providers in a debug mode in eclipse

Rashmi Singh singhrasster at gmail.com
Sat Jul 2 20:13:01 EDT 2016


Thanks for your reply Francis. I still have one problem:

When I run this:
$ docker run --name keycloak1 -p 8080:8080 -p 8787:8787 jboss/keycloak

I can access the keycloak app console on http://192.168.99.100:8080/auth/
from my browser

But when I run it in debug mode as:
$ docker run --name keycloak1 -p 8080:8080 -p 8787:8787 jboss/keycloak
--debug

I cannot access the keycloak console. What is wrong here, any idea?

On Fri, Jul 1, 2016 at 12:48 AM, Francis Pouatcha <
francis.pouatcha at adorsys.com> wrote:

> Rashmi,
>
> follow these instructions to have keycloack debug accessible from eclipse:
>
> 1- Simple web application
> User a simple HelloServlet to try out the debugging process before
> applying you experience to wildfly.
>
> 1- Wildfly and eclipse
> Like Thomas mentioned, Make sure you active the debug property while
> starting wildfly. This is independent of keycloak, as keycloak is just
> another web application running on wildfly. So make sure you have a simple
> webapp running in wildfly standalone so you can get used to the debugging
> process.
>
> 2- Wildfly in a docker container
> Take your simple web application and wildfly into a docker container and
> try following:
> a) Make sure you start wildfly in the container in debug mode. Not matter
> how you manage the docker containers in your development environment, you
> will have to expose their ports so you can reach the container from and
> outside the docker host. "Exposing the port means mapping the defined
> wildfly ports to some other ports on the docker host. If you are using
> docker-composer you have to try something like:   ports:\    - "8080:8080"\
>    - "8787:8787". In this case see the docker-compose reference for details.
>
> 3- Accessing the docker container
> Once you wildfly docker container is startet in debug mode, make sure you
> can access you HelloServlet  from a web browser on the same machine on
> which you have your eclipse installed. If this works, use the same hostname
> or ip to replace "localhost" in you eclipse debugging config. Generally
> this will default to: 192.168.99.100:8787.
>
> You did it right, you will be able to stop on the breakpoint inside your
> HelloServlet.
>
> 4- Keycloak
> Repeat the same procedure with your custom authenticator. Do not forget to
> download the keycloak sources and include them in your the source path so
> you can navigate and set break points.
>
>
> Best regards
> Mit freundlichen Grüßen
> Cordialement
>
> Francis Pouatcha
> Founder and Technical Lead Group Adorsys
>
> LinkedIn: http://www.linkedin.com/pub/francis-pouatcha/8/35a/542
> adorsys GmbH & Co. KG, Germany:
> http://www.youtube.com/watch?v=rVRkFGUNexo&authuser=0
> Adorsys S.A., Cameroon: "African Software Competence Center"
> Open https://github.com/adorsys
>
> Cell USA: +1 770 329 7026
> Cell Germany: +49 172 18 16 074
> Cell Cameroon: +237 51 74 71 99
>
>
> On Fri, Jul 1, 2016 at 2:39 AM, Rashmi Singh <singhrasster at gmail.com>
> wrote:
>
>> Thanks Thomas for your reply. I have a few questions on your response. I
>> am still very new to docker, so please bear with me.
>> when you say I can set env variables in docker container, would this be
>> sufficient?
>>
>> First connect to the docker container as:
>>
>> docker exec -i -t keycloak bash
>> Then, once I am in the container, I run the following to set env
>> variables?
>>
>> set DEBUG_MODE=true
>> set DEBUG_PORT=8787
>> exit
>> Then, restart the container as:
>> docker restart keycloak    (keycloak is the name of my container)
>> Also, how can I make sure that the env variable got correctly set in the
>> docker container? From inside the container, if I run the command "env",
>> should it list these new env variables if they are added successfully?
>>
>> Then, when you say "......default on port 8787 which you need to expose
>> on your docker container or use the container interface...", what exactly
>> do you mean? Do you mean some sort of port forwarding? Could you tell me w
>> tohat exactly I need to do with my existing container named as "keycloak"
>>
>> Then, on eclipse, where you mentioned the settings for the Debug
>> configurations, what should be the hostname there? would it be localhost?
>> or the default machine IP of docker which is 192.168.99.100? Or it should
>> be something else?
>>
>>
>>
>> On Thu, Jun 30, 2016 at 6:29 PM, Thomas Darimont <
>> thomas.darimont at googlemail.com> wrote:
>>
>>> Hello,
>>>
>>> you could add -debug flag to the standalone.sh command-line or define
>>> the following env variables in your docker container:
>>> set DEBUG_MODE=true
>>> set DEBUG_PORT=8787
>>>
>>> this will start keycloak with remote debugging enabled by default on
>>> port 8787 which you need to expose on your docker container or use the
>>> container interface...
>>>
>>> you can then connect to the keycloak instance inside the docker
>>> container via the remote debugger from your IDE.
>>> For eclipse just go to "Debug configurations..." -> Remote Java
>>> Application -> select your project with the custom authenticator -> adjust
>>> hostname and port and click "debug".
>>>
>>> Cheers,
>>> Thomas
>>>
>>> 2016-07-01 0:26 GMT+02:00 Rashmi Singh <singhrasster at gmail.com>:
>>>
>>>> We have a Maven project setup on Eclipse that uses some keycloak
>>>> features and we generate a jar that contains our AuthenticationProvider
>>>> classes etc.
>>>> We use docker for the deployment. We basically run a jboss/keycloak
>>>> image there
>>>> We have a shell script that has a bunch of commands to copy our project
>>>> jars from local to the keycloak image on docker container like:
>>>>
>>>> docker cp /customauthenticator-1.0.0-SNAPSHOT.jar
>>>> keycloak:/home/modules/xxx.yyy.zz.keycloak.customizations
>>>> ....
>>>> docker restart keycloak
>>>>
>>>> Running this shell script deploys everything on keycloak on docker.
>>>> And so far we are just putting logs throughout our code to debug issues.
>>>> We want to be able to setup a debugging environment on our eclipse. I
>>>> am not sure how to achieve this when we use keycloak. Because, here we
>>>> basically build our modules or authenticator jars etc and copy them to
>>>> keycloak directories. So, it's not a standalone project war file that we
>>>> are directly deploying to app server as such. So, then how do we put our
>>>> maven project (creating jars etc) in a debug mode in eclipse? Is it
>>>> possible? How?
>>>>
>>>> _______________________________________________
>>>> keycloak-dev mailing list
>>>> keycloak-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>>>
>>>
>>>
>>
>> _______________________________________________
>> keycloak-dev mailing list
>> keycloak-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20160702/4ff6b61d/attachment-0001.html 


More information about the keycloak-dev mailing list