Key point: Entity expansion happens during XML parsing.
Case 1
In case 1, during parsing, there are no entities in Resources/@name
– just ${app.name}
, which the program calling the XML parser would presumably go on to substitute the literal text, or
, for the variable:
<Resource name="or" />
Downstream processing likely doesn't know how to deal with or
, and you have your "not working" case.
Case 2
In case 2, or
exists in the XML file prior to parsing. After parsing, effectively, the program calling the XML parser sees the entities expanded:
<Resource name="or" />
and is able to "work" because it knows what to do when @name
is "or"
.
Note that had catalina.properties
been an XML file, the expansion would have occurred then that file was parsed, and you'd be back to your "working" case.
Solution
Options include one of the following:
- Hardwire the entities in
server.xml
rather than in catalina.properties
.
- Force the property substitution to happen prior to XML parsing of
server.xml
.
- Use Unicode characters directly (not encoded as XML entities) in your
catalina.properties
file.