How to add Elytron jdbc-realm in embed-server mode? (wildfly16)
daveagill Jun 26, 2019 9:42 AMI am trying to add a configure a jdbc-realm using the jboss-cli in "embed-server" mode but it keeps failing.
I have managed to condense my problem down to a minimal example on a completely clean Wildfly16 install, if I run the following commands in jboss-cli:
embed-server --server-config=standalone.xml
/subsystem=elytron/jdbc-realm=MyRealm:add(principal-query=[{sql="SELECT hash, salt, iters FROM Users WHERE username = ?", data-source=ExampleDS}])
Then I get the following output:
ERROR [org.jboss.as.controller.management-operation] (pool-3-thread-1) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "elytron"),
("jdbc-realm" => "MyRealm")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["org.wildfly.data-source.ExampleDS"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["org.wildfly.security.security-realm.MyRealm is missing [org.wildfly.data-source.ExampleDS]"]
}
{
"outcome" => "failed",
"failure-description" => {
"WFLYCTL0412: Required services that are not installed:" => ["org.wildfly.data-source.ExampleDS"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["org.wildfly.security.security-realm.MyRealm is missing [org.wildfly.data-source.ExampleDS]"]
},
"rolled-back" => true
}
The ExampleDS is defined in the default standalone.xml shipped with wildfly16 but it doesn't make any difference if I define my own datasource first, I get the same error.
And I can confirm that the embedded server 'knows' about the Example DS:
/subsystem=datasources:read-resource
{
"outcome" => "success",
"result" => {
"data-source" => {"ExampleDS" => undefined},
"jdbc-driver" => {"h2" => undefined},
"xa-data-source" => undefined
}
}
If I run the embed-server command with --admin-only=false then the jdbc-realm can be added successfully.
So it would seem the data-sources are not installed when starting with an embedded server in the admin-only mode.
I can't tell if this is expected behaviour, a bug or if I'm just doing something wrong?
Any help much appreciated, thanks.