I added things like the following to my context.xml file in the META-INF directory of my webapp:
<Environment name="maxExemptions" value="10" type="java.lang.Integer"/>
So that during execution I could do load the variable and use it like so:
After I deployed my new code, I tested it and found out quickly that the javax.naming.NamingException were being throw. The error basically stated that the variable was not bound in this context.
Context c = new InitialContext();
String maxExemptions =
((Integer)c.lookup("java:comp/env/maxExemptions")).intValue();
At first I thought that I did the whole looking up stored properties incorrectly. What really happened though, was that in my
/${catalina.home}/conf/Catalina/localhost/
directory was a cached copy of my context.xml file under the name of 'my_webapps_name'.xml.
Once I deleted that and restarted Tomcat, everything worked as expected.
If you came here trying to debug javax.naming.NamingExceptions, I recommend that you first try removing that file first!
Good Luck!
1 comment:
Thank you so much for the tip! Saved my day ;-)
Post a Comment