cas-management overlay 6.6.3 with support-mongo-service-registry does not bind cas properties

56 views
Skip to first unread message

martin....@springer.com

unread,
Jul 27, 2023, 1:01:37 PM7/27/23
to CAS Community
Hi cas-users,

We generated a minimal cas-management overlay using
 

Setting cas.service-registry.mongo.client-uri=mongodb://localhost/somedb in etc/cas/config/management.properties

results in 

Caused by: java.lang.IllegalArgumentException: The connection string is invalid. Connection strings must start with either 'mongodb://' or 'mongodb+srv://
        at com.mongodb.ConnectionString.<init>(ConnectionString.java:303) ~[mongodb-driver-core-4.7.1.jar!/:?]
        at org.apereo.cas.mongo.MongoDbConnectionFactory.mongoDbFactory(MongoDbConnectionFactory.java:191) ~[cas-server-support-mongo-core-6.6.0.jar!/:6.6.0]
        at org.apereo.cas.mongo.MongoDbConnectionFactory.buildMongoTemplate(MongoDbConnectionFactory.java:287) ~[cas-server-support-mongo-core-6.6.0.jar!/:6.6.0]
        at org.apereo.cas.config.MongoDbServiceRegistryConfiguration.mongoDbServiceRegistryTemplate(MongoDbServiceRegistryConfiguration.java:50) ~[cas-server-support-mongo-service-registry-6.6.0.jar!/:6.6.10]

No matter how we try, the mandatory db config value are never getting bound to CasConfigurationProperties. 

But, actually we are able to start cas-management using system properties: 

java -Dcas.service-registry.mongo.client-uri=mongodb://localhost/somedb -jar build/libs/cas-management.war

Is this a known problem?

Where and how should cas.service-registry.mongo.client-uri be set using a properties file?

Regards

Martin


Ray Bon

unread,
Jul 27, 2023, 3:16:23 PM7/27/23
to cas-...@apereo.org
Martin,

This logger may help:

<AsyncLogger name="org.apereo.cas.config" level="debug" />

I also have this line in my log output:
cas | 2023-07-27 19:10:08,677 INFO [ org.aper.cas.util.io.PathWatcherService] - <Watching directory path at [/etc/cas/config]> [main]

Check to make sure it is looking in the correct place for management.properties (even though /etc/cas/config is the default).

Ray

On Thu, 2023-07-27 at 09:17 -0700, 'martin....@springer.com' via CAS Community wrote:
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.

martin....@springer.com

unread,
Jul 28, 2023, 4:05:23 AM7/28/23
to CAS Community, Ray Bon
Hi Ray,

We are upgrading, from 6.4.3, the props have been working in these locations.

After a day of debugging it turned out that there is some race condition in spring boot about app context creation. Upgrading to springboot to 2.7.14 seems to solve it.

Have a good one

Martin

Conrad Finkelstein

unread,
Jul 28, 2023, 5:26:27 AM7/28/23
to CAS Community, martin....@springer.com, Ray Bon
Hello everybody, 

the thing is that SpringBoot comes along if the SpringCloud configuration which basically creates two application context initialisation steps after server startup (independent if SpringCloud config is deactivated or not => ).

The application.properties no matter where they are defined will be loaded in the second bootstrap step. But the CasConfigurationProperties will be loaded with the first Application Context - and the properties are not available here.

So what I did is to move to SpringBoot 2.7.14 and changed the file names to bootstrap-<profile>.properties.
Now the properties will be used for both initialisations. 

I am not a Spring expert. This is what I found while debugging.

Best regards,
Conrad
Reply all
Reply to author
Forward
0 new messages