0

If in app.xml someone has provided commented like this:

<!-- ${<>} -->
or <!-- ${lion} -->
or <!-- ${something} -->

Now this lion/something is not defined anywhere it says variable cannot be resolved. then tomcat is not starting. How to solve this

2 Answers2

0

Tomcat treats this as an EL expression and tries to evaluate it. Expression "<>" is obviously incorrect one and can't be parsed (that's what error text is about).

You need to escape this text to prevent Tomcat from parsing it:

<!-- &#36{<>} -->

See "How to escape EL dollar signs?" for details.

Sergey
  • 448
  • 1
  • 4
  • 16
  • @mayanksingh , can you try the second option: ? – Sergey May 21 '18 at 09:14
  • yeahh it started, But why $ ? –  May 21 '18 at 09:23
  • With this Tomcat will not try to evaluate the expression (it will not be considered as an expression by Tomcat), but from XML point of view "$" is the same text as "$". I.e. in DOM model (would you want to analyze app.xml in your program) it still will be understood as "${<>}". – Sergey May 21 '18 at 09:26
  • OKay that is the xml numeric representation for $. So i'm going to handle such cases. because i'm not supposed to ask someone to add $ in place of $. –  May 21 '18 at 09:30
  • how to handle $ as $ in java any library i'm using org.apache.commons.el.ExpressionEvaluatorImpl and javax.servlet.jsp.el.* 2.0 –  May 21 '18 at 12:46
  • I don't quite understand what exactly are you trying to do. Why do you want to handle it that way? – Sergey May 21 '18 at 12:48
  • No, i mean if some else has written then my code should handle this. that how can i do –  May 22 '18 at 04:45
  • Well, the first qustion will be -- where the app.xml is placed (in what localtion) and what are you planning to do with this file? – Sergey May 22 '18 at 09:06
  • i've edited the question and this time it is correct last i didn't understand the context –  May 22 '18 at 10:20
0

If someone had defined any variable in the comment(s) of app.xml and that variable is not set in environment variable then i'm setting its value to null in resolveVariable method from VariableResolver. And it worked from me, server got started