I update my spring configuration file on runtime, and i validate updated version of configuration file before i overwrite it. My solution for it was doing a transformation from xml to object, so if it fails i know that it has a problem. And my code is something like as follows;
ApplicationContext context = new FileSystemXmlApplicationContext();
context.setConfigLocation(path);
try {
context.refresh();
} catch (RuntimeException e) {
log.error(e);
}
Object myObject = context.getBean("myBean");
I didn't have a problem on my local server. It is a Windows 10 machine. But when i run my project on my remote server (Red Hat Enterprise Linux 8.7) it gets stuck for awhile on refresh() then throws the RuntimeException. The exception is like as follows;
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 386; cvc-elt.1.a: Cannot find the declaration of element 'spring:beans'.
I'd like to know what causes it to throw an exception when environment changes. Thanks in advance.