You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Alexandre Corrêa Barbosa <al...@gmail.com> on 2007/05/30 22:10:12 UTC

Tiles causes EvaluationException in MyFaces

Hello guys,

I'm using Tiles 2.0.3, with MyFaces 1.1.5 and Tomahawk 1.1.5 into JBoss
4.0.5.
I'm trying to build a h:selectOneMenu, using f:selectItems to define it's
options, like in the following code:

<t:selectOneMenu id="compId" value="#{MyBean.objectId}"
required="true" >
<f:selectItems value="#{MyBean.objectItems}"/>
</t:selectOneMenu>


With the following code for my backingBean, it works fine:

public class MyBean {
>
>    private int objectId = 0;
>
   private List<SelectItem> objectItems = null;
>
>    public MyBean() throws Exception {
>       objectItems = new ArrayList<SelectItem>();
>       objectItems.add( new SelectItem( 0, "" ) );
>       objectItems.add( new SelectItem( 1, "Object1 ) );
>       objectItems.add( new SelectItem( 2, "Object2 ) );
>       objectItems.add( new SelectItem( 3, "Object3 ) );
>       objectItems.add( new SelectItem( 4, "Object4 ) );
>     }
>
>     public List<SelectItem> getObjectItems() {
>        return objectItems;
>     }
>
>     public int getObjectId() {
>        return objectId;
>     }
>
>     public void setObjectId(int objectId) {
>        this.objectId = objectId;
>     }
> }



But, if I change the objtecItems initialization, performing a Db search, and
using the results to populate it, like in the following:


public MyBean() throws Exception {
>                 List<MyObject> objects = dbObject.doSearch();
>                     objectItems = new ArrayList<SelectItem>();
>                     for( MyObject obj : objects ) {
>                       /* obj.getInt() returns an int, and obj.getString()
> a String */
>                       objectItems.add( new SelectItem( obj.getInt(),
> obj.getString() ) );
>                     }

}
>

I got an error when trying to load the page into jboss log:

15:01:03,610 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
javax.faces.el.EvaluationException: Cannot get value for expression '#{
PalmBatch.varietyItems}'
        at org.apache.myfaces.el.ValueBindingImpl.getValue(
ValueBindingImpl.java:405)
        at javax.faces.component.UISelectItems.getValue(UISelectItems.java
:58)
        at
org.apache.myfaces.shared_tomahawk.util.SelectItemsIterator.hasNext(
SelectItemsIterator.java:105)
        at
org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.internalGetSelectItemList
(RendererUtils.java:450)
        at
org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getSelectItemList
(RendererUtils.java:428)
        at
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.internalRenderSelect
(HtmlRendererUtils.java:294)
        at
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.renderMenu
(HtmlRendererUtils.java:267)
        at
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMenuRendererBase.encodeEnd
(HtmlMenuRendererBase.java:59)
        at org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer.encodeEnd(
HtmlMenuRenderer.java:60)
        at javax.faces.component.UIComponentBase.encodeEnd(
UIComponentBase.java:539)
        at
org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(
RendererUtils.java:419)

But checking the tiles log, I've got the following exception:
2007-05-30 16:57:18,341 2388021 DEBUG [org.apache.tiles.jsp.context.JspUtil]
(http-0.0.0.0-8180-1:) Unable to execute JSP 2.0 include method.  Trying old
one.
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:82)
        at org.apache.tiles.jsp.context.JspTilesRequestContext.include(
JspTilesRequestContext.java:88)
        at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(
JspTilesRequestContext.java:82)
        at org.apache.tiles.impl.BasicTilesContainer.render(
BasicTilesContainer.java:460)

And also the following exception (that I think it's thrown after tiles try
the old include method)

2007-05-30 16:57:18,978 2388658 ERROR [
org.apache.tiles.jsp.context.JspTilesRequestContext] (http-0.0.0.0-8180-1:)
JSPException while including path '/solicLotePalm.jsp'.
javax.servlet.jsp.JspException: ServletException while including page.
        at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:98)
        at org.apache.tiles.jsp.context.JspTilesRequestContext.include(
JspTilesRequestContext.java:88)
        at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(
JspTilesRequestContext.java:82)
        at org.apache.tiles.impl.BasicTilesContainer.render(
BasicTilesContainer.java:460)
        at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(
InsertAttributeTag.java:141)
        at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(
InsertAttributeTag.java:118)
        at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(
RenderTagSupport.java:172)
        at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(
RoleSecurityTagSupport.java:76)
        at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(
ContainerTagSupport.java:82)

I've removed the jsf-libs that comes with jboss, packed all the needed jar
into my .war, and the error is still the same. Someone could give me a hint
on that?

Thanks in advance,
Alexandre
-- 
Alexandre Corrêa Barbosa
http://mydevelopmentjournal.blogspot.com (meu blog de tecnologia)
http://log4dev.wordpress.com (blog de tecnologia de Miguel Galves, onde sou
colaborador)

Re: Tiles causes EvaluationException in MyFaces

Posted by Greg Reddin <gr...@gmail.com>.
On 5/30/07, Alexandre Corrêa Barbosa <al...@gmail.com> wrote:
>
> Hello guys,
>
> I'm using Tiles 2.0.3, with MyFaces 1.1.5 and Tomahawk 1.1.5 into JBoss
> 4.0.5.
> I'm trying to build a h:selectOneMenu, using f:selectItems to define it's
> options, like in the following code:
>
> <t:selectOneMenu id="compId" value="#{MyBean.objectId}"
> required="true" >
> <f:selectItems value="#{MyBean.objectItems}"/>
> </t:selectOneMenu>


Given the code you're using it doesn't really sound like Tiles is the
problem. Even the Tiles exceptions you noted could be pointing to some
deeper error that's getting thrown. I'm not currently using Tiles with JSF;
I'm using Facelets. But I've seen a lot of issues where my code blows up
somewhere and it gets rendered in the browser and in the Tomcat log as a
Facelets or JSF error. If I debug my code or turn up logging I find my own
code is throwing an exception. I'd verify that first. This statement
especially leads me to believe this is the case:

With the following code for my backingBean, it works fine:


I got an error when trying to load the page into jboss log:
>
> 15:01:03,610 ERROR [[jsp]] Servlet.service() for servlet jsp threw
> exception
> javax.faces.el.EvaluationException: Cannot get value for expression '#{
> PalmBatch.varietyItems}'


I could see this error occuring if your database object fails to load the
SelectItems components.

But checking the tiles log, I've got the following exception:
> 2007-05-30 16:57:18,341 2388021 DEBUG [
> org.apache.tiles.jsp.context.JspUtil]
> (http-0.0.0.0-8180-1:) Unable to execute JSP 2.0 include method.  Trying
> old
> one.
> java.lang.reflect.InvocationTargetException
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:82)
>         at org.apache.tiles.jsp.context.JspTilesRequestContext.include(
> JspTilesRequestContext.java:88)
>         at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(
> JspTilesRequestContext.java:82)
>         at org.apache.tiles.impl.BasicTilesContainer.render(
> BasicTilesContainer.java:460)
>
> And also the following exception (that I think it's thrown after tiles try
> the old include method)
>
> 2007-05-30 16:57:18,978 2388658 ERROR [
> org.apache.tiles.jsp.context.JspTilesRequestContext] (http-0.0.0.0-8180-1:
> )
> JSPException while including path '/solicLotePalm.jsp'.
> javax.servlet.jsp.JspException: ServletException while including page.
>         at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:98)
>         at org.apache.tiles.jsp.context.JspTilesRequestContext.include(
> JspTilesRequestContext.java:88)
>         at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(
> JspTilesRequestContext.java:82)
>         at org.apache.tiles.impl.BasicTilesContainer.render(
> BasicTilesContainer.java:460)
>         at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(
> InsertAttributeTag.java:141)
>         at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(
> InsertAttributeTag.java:118)
>         at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(
> RenderTagSupport.java:172)
>         at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(
> RoleSecurityTagSupport.java:76)
>         at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(
> ContainerTagSupport.java:82)


How are you using Tiles? Are you using the Shale TilesViewHandler, some
other Tiles ViewHandler, or just using Tiles apart from  JSF altogether?

Thanks,
Greg