Hi everyone,
I wanted to share a solution to an issue that cost me several hours of
troubleshooting. If you're running CAS 7.1.x in standalone mode on an
external servlet container (like Tomcat) and wondering why automatic
configuration file watching isn't working, here's what I found.
*The Problem:* The CAS documentation states that in standalone mode with
spring.cloud.config.enabled=false, CAS will automatically watch and monitor
configuration files for changes. Despite having the
cas-server-core-events-configuration dependency and running in standalone
mode, file changes to /etc/cas/config/cas.properties weren't triggering
automatic reloads. Manual refresh via /actuator/refresh worked fine, but
automatic file watching did nothing.
*The Solution:* Add this property to your cas.properties:
properties
cas.events.core.track-configuration-modifications=true
*How I Found It:* While digging through the CAS source code, I stumbled on
a test file (CasConfigurationEventListenerTests) that led me to
CasCoreConfigurationWatchAutoConfiguration. The critical piece is in the
bean definition:
java
@Bean public InitializingBean casConfigurationWatchService( final
ConfigurableApplicationContext applicationContext) { return BeanSupplier.of(
InitializingBean.class) .when(BeanCondition.on(
"cas.events.core.track-configuration-modifications").isTrue() .given
(applicationContext.getEnvironment())) .supply(() -> new
CasConfigurationWatchService(applicationContext)) .otherwiseProxy() .get();
}
The CasConfigurationWatchService bean only gets created when
BeanCondition.on("cas.events.core.track-configuration-modifications").isTrue().
Without this property set to true, the file watcher never initializes.
*The Documentation Gap:* This required property is not mentioned anywhere
in the "Configuration Management - Reloading Changes" documentation. The
feature is disabled by default, and there's no indication in the docs that
you need to explicitly enable it.
*Verification:* After adding the property and restarting, I can now see the
automatic reload messages in the logs when I modify cas.properties. The
file watcher works exactly as described in the documentation - but only
with this undocumented flag enabled.
*CAS Version:* 7.1.6
*Deployment:* WAR to Tomcat 11
*Profile:* standalone
Hope this saves someone else the troubleshooting time. If anyone from the
CAS team is reading this, it would be great to see this property documented
in the Configuration Reloading section.
--
- Website: https://apereo.github.io/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/a/apereo.org/d/msgid/cas-user/bcc33d70-233d-4dc2-b191-0910191f7777n%40apereo.org.