How to use UAA with mysql via config uaa.yml?

788 views
Skip to first unread message

AliBaBa

unread,
Sep 22, 2013, 2:58:51 AM9/22/13
to vcap...@cloudfoundry.org
Hi,All

I'm trying to use UAA as an OAuth2 server for a project,I had tested it by passing the spring.profiles.active parameter to the JVM or by modifying the <beans profile="mysql"> to <beans profile="default,mysql"> in env.xml successfully

Yet for all that,I think the best way to use mysql is uaa.yml

I found the uaa.yml in this path : "UAA/src/main/resources/uaa.yml" ,and the default text was:

# Configuration in this file is overridden by an external file
# if any of these exist: 
# [$UAA_CONFIG_URL, $UAA_CONFIG_PATH/uaa.yml, $CLOUDFOUNDRY_CONFIG_PATH/uaa.yml]

then I added mysql configuration:

# Configuration in this file is overridden by an external file
# if any of these exist: 
# [$UAA_CONFIG_URL, $UAA_CONFIG_PATH/uaa.yml, $CLOUDFOUNDRY_CONFIG_PATH/uaa.yml]

spring_profiles: mysql

database:
   driverClassName: org.mariadb.jdbc.Driver
   url: jdbc:mysql://localhost:3306/uaa
   username: root
   password: 1

scim:
   users:
      - admin|c1oudc0w|scim.write,scim.read,openid

But it was 
Invalid,the UAA server always using the hsqldb

By checking,I found UAA server always loaded "file:${CLOUD_FOUNDRY_CONFIG_PATH}/uaa.yml" ,and in the java file:YamlServletProfileInitializer.java

private Resource getResource(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext,
String locations) {
Resource resource = null;
String[] configFileLocations = locations == null ? DEFAULT_PROFILE_CONFIG_FILE_LOCATIONS : StringUtils
.commaDelimitedListToStringArray(locations);
for (String location : configFileLocations) {
location = applicationContext.getEnvironment().resolvePlaceholders(location);
servletContext.log("Testing for YAML resources at: " + location);
resource = applicationContext.getResource(location);
if (resource != null && resource.exists()) {
break;
}
}
return resource;
}

when the value of  "resource" is file:${CLOUD_FOUNDRY_CONFIG_PATH}/uaa.yml, resource.exists() is false,but the return resource always is file:${CLOUD_FOUNDRY_CONFIG_PATH}/uaa.yml

is't a bug?




Dave Syer

unread,
Sep 24, 2013, 5:48:37 AM9/24/13
to vcap...@cloudfoundry.org
On 22/09/13 07:58, AliBaBa wrote:
> then I added mysql configuration:

Where did you put your uaa.yml, and how did you set up your environment
(which of the optional env vars/system properties UAA_CONFIG_URL,
UAA_CONFIG_PATH, CLOUDFOUNDRY_CONFIG_PATH are set in your system)?

> By checking,I found UAA server always loaded
> "file:${CLOUD_FOUNDRY_CONFIG_PATH}/uaa.yml"

If that file doesn't exist how can it be loaded? You should see in the
server startup logs where the file is found and loaded from (and the
values it reads).

It all works for other people (and we use MySQL in production at
run.pivotal.io), so there must be something simple you need to do to get
your file in the right location.

D.

AliBaBa

unread,
Sep 25, 2013, 3:09:46 AM9/25/13
to vcap...@cloudfoundry.org
Thanks Dave,

1. I changed "UAA/src/main/resources/uaa.yml" without moving it,and it appeared under target/classes directory.

2.I didn't set any one of these system properties "UAA_CONFIG_URL, UAA_CONFIG_PATH, CLOUDFOUNDRY_CONFIG_PATH",according to the comment in the default file 'uaa.yml' : 
# Configuration in this file is overridden by an external file
# if any of these exist"
# [$UAA_CONFIG_URL, $UAA_CONFIG_PATH/uaa.yml, $CLOUDFOUNDRY_CONFIG_PATH/uaa.yml]
I thought its meaning is that configurations in this file will be valid if the system properties "UAA_CONFIG_URL, UAA_CONFIG_PATH, CLOUDFOUNDRY_CONFIG_PATH" aren't existing.

在 2013年9月24日星期二UTC+8下午5时48分37秒,Dave Syer写道:

Dave Syer

unread,
Sep 26, 2013, 9:52:06 AM9/26/13
to vcap...@cloudfoundry.org
On 25/09/13 03:09, AliBaBa wrote:
I changed "UAA/src/main/resources/uaa.yml" without moving it,and it appeared under target/classes directory.

OK, so that should work, but only (obviously) if you actually deploy that file to Tomcat (e.g. by rebuilding a war and deploying that, or re-running whatever command you use to launch it (e.g. mvn tomcat:run).

AliBaBa

unread,
Sep 27, 2013, 6:26:54 AM9/27/13
to vcap...@cloudfoundry.org
In fact,the uaa.yml was deployed to Tomcat,the path is 'Tomcat-7.0.25\webapps\uaa\WEB-INF\classes\uaa.yml',but it always invalid.

在 2013年9月26日星期四UTC+8下午9时52分06秒,Dave Syer写道:

Dave Syer

unread,
Sep 27, 2013, 8:35:05 AM9/27/13
to vcap...@cloudfoundry.org
On 27/09/13 06:26, AliBaBa wrote:
> In fact,the uaa.yml was deployed to Tomcat,the path is
> 'Tomcat-7.0.25\webapps\uaa\WEB-INF\classes\uaa.yml',but it always invalid.

Maybe there's a syntax error in it (whitespace is significant in YAML so
that can be a problem for example), or a bad property name (what you
posted before looked OK though).

Just a thought: why is it "Tomcat-7.0.25\webapps\uaa"? You did want it
to be deployed as /uaa (we usually run it as ROOT so it shows up on /)?
Maybe you have 2 instances running and you are looking at the wrong one?
Reply all
Reply to author
Forward
0 new messages