Reputation: 8837
I have an f:loadBundle that loads a properties file from my classpath.
<f:loadBundle basename="com.xxx.ui.messages" var="msg" />
Later on, I'm attempting to use a message from the resource bundle with the following syntax:
<h:outputText value="test message: #{msg.does_not_exist} --"/>
It used to be that JSF would print out a "NOT FOUND" message, but now it's throwing an exception. Did the specification change or is this the correct behavior?
I'm using Mojarra 2.1.9 with JUEL 2.2.4 as a EL resolver. Here's the stack trace:
javax.el.PropertyNotFoundException: /WEB-INF/xxx.xhtml @10,70 value="test message: #{msg.does_not_exist} --": Property 'does_not_exist' not found on type java.util.PropertyResourceBundle
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
EDIT: The correct behavior can be verified here: http://javaserverfaces.java.net/nonav/docs/2.0/vdldocs/facelets/f/loadBundle.html
(Which says the literal string ???KEY??? is returned from the Map, where KEY is the key being looked up in the Map, instead of a MissingResourceException being thrown)
EDIT: Same problem even after removing JUEL
Upvotes: 2
Views: 1272
Reputation: 8837
So the answer is actually staring you in the face... props to @millimoose for getting me started down the right path.
Notice the specification says this:
the literal string ???KEY??? is returned from the Map, where KEY is the key being looked up in the Map, instead of a MissingResourceException being thrown.
But my stack trace says this:
javax.el.PropertyNotFoundException: /WEB-INF/xxx.xhtml @10,70 value="test message: #{msg.does_not_exist} --": Property 'does_not_exist' not found on type java.util.PropertyResourceBundle
Ahah, a possible bug!
Knowing that this class would be pulled from tomcat/lib, I browsed out to their source and javadoc here. Notice the throws declaration on "getValue()"?
That's in pretty stark contrast to the specification here.
So I removed el-api from tomcat/lib and replaced it with the spec jar (here) and problem solved!
Why Tomcat is so different from the specification is beyond me... those crazy Apache guys.
Upvotes: 3