Unable to create users in Payara Micro in Docker

422 views
Skip to first unread message

Morten Hindsholm

unread,
Feb 23, 2018, 9:05:12 AM2/23/18
to Payara Forum
Hi there

I am trying to run integration tests for my JEE application in a Payara Micro server inside Docker. In order to test, I need a couple of users in different groups. For that I thought I could use some asadmin commands in a post-boot-command script, but I have run into some problems.

I have recorded the user creation in the admin console where I created two users with empty passwords (this is just an integration test, so empty passwords are fine). My Dockerfile is like this:
FROM payara/micro
COPY
./target/bank.war /opt/payara/deployments
COPY
./src/test/payara/post-boot-commands.txt /opt/payara
ENTRYPOINT
[]
CMD
["/usr/bin/java", "-jar", "/opt/payara/payara-micro.jar", "--nocluster", "--deploymentDir", "/opt/payara/deployments", "--postbootcommandfile", "/opt/payara/post-boot-commands.txt"]

and post-boot-commands.txt is:
create-file-user --groups=customers customer
create
-file-user --groups=advisors advisor

Nice and simple :) However, this will not run, I get this error twice:
[2018-02-23T12:09:18.125+0000] [] [WARNING] [] [fish.payara.micro.boot.runtime.BootCommand] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1519387758125] [levelValue: 900] [[
 
Boot Command create-file-user failed PlainTextActionReporterFAILUREorg.jvnet.hk2.config.UnsatisfiedDependencyException: injection failed on com.sun.enterprise.security.cli.CreateFileUser.userpassword with class java.lang.StringDescription: create-file-user commandCannot find userpassword in create-file-user command model, file a bug
   
Usage: create-file-user
   
[--authrealmname <authrealm_name>] [--target target]
   
[--groups user_groups[:user_groups]*]
   
[-?|--help[=<help(default:false)>]] username
]]

So apparently I cannot use empty passwords(?)

I then added a password.txt file:
AS_ADMIN_USERPASSWORD=passw0rd

and changed post-boot-commands.txt to:
create-file-user --passwordfile /opt/payara/password.txt --groups=customers customer
create
-file-user --passwordfile /opt/payara/password.txt --groups=advisors advisor

but now I get this error:
[2018-02-23T12:18:55.801+0000] [] [WARNING] [] [fish.payara.micro.boot.runtime.BootCommand] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1519388335801] [levelValue: 900] Boot Command create-file-user failed PlainTextActionReporterFAILUREThe specified physical file /tmp/payaramicro-rt192260533805564173tmp/config/keyfile associated with the file realm file does not exist.

Apparently the keyfile is missing, but when i do an ls in the config directory listed in the error message, it contains an empty keyfile.

I apologize if this is just because I am a Payara noob, but I would really appreciate some help on this simple task: adding two users :)

/morten













Morten Hindsholm

unread,
Feb 26, 2018, 9:56:58 AM2/26/18
to Payara Forum
Apparently this has nothing to do with Docker.
There is a bug in Payara Micro which I have now reported.

/Morten

Ondro Mihályi

unread,
Mar 3, 2018, 9:47:03 AM3/3/18
to Payara Forum
Hi,

In Payara Micro, when you use commands that require a password, you need to provide the password via a password file because Payara Micro can't ask for a password interactively. I've written a blog post about using password files in scripts with Payara Server and it applies also to Payara Micro for commands executed from command files: https://itblog.inginea.eu/index.php/configure-passwords-in-payara-server-and-glassfish/

On thing to note is that asadmin commands can be executed in different points during startup:
- after Payara Micro is started but before the server is ready - these are commands in a prebootcommandfile
- after Payara Micro server is ready but before applications are deployed - these are commands in a postbootcommandsfile
- after applications are deployed - these are commands in a postdeploycommandfile

Only few commands work when in a prebootcommandfile. Most commands work in a postbootcommandfile. But still some require applications to be deployed and work only in a postdeploycommandfile.

It's not yet documented which commands work in which command file because it would be a tedious task to find it out and document.

It seems that there's a bug in Payara Micro that requires that the command create-file-user is executed from a postdeploycommandfile while there's no obvious reason for that. Another workaround is to modify payara-micro.jar and create an empty file MICRO-INF/domain/keyfile in the JAR.

Ondro
Reply all
Reply to author
Forward
0 new messages