2 Replies Latest reply on Dec 13, 2007 2:48 PM by Maximiliano Carrizo

    IllegalArgumentException: value of context variable is not a

    None None Master

      What could cause this exception:

      Caused by: java.lang.IllegalArgumentException: value of context variable is not an instance of the component bound to the context variable: price
       at org.jboss.seam.Component.getInstance(Component.java:1639)
       at org.jboss.seam.Component.getInstance(Component.java:1594)
       at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:46)
       at org.apache.myfaces.custom.redirectTracker.RedirectTrackerVariableResolver.resolveVariable(RedirectTrackerVariableResolver.java:41)
       at org.apache.myfaces.custom.security.SecurityContextVariableResolver.resolveVariable(SecurityContextVariableResolver.java:45)
       at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
       at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:574)
       at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
       at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
       at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
       ... 40 more
      


      This is totally baffling to me. I have a form which displays fine, and then when I try to change the price.foo setting and hit "submit", I get a "EvaluationException: Cannot get value for expression '#{price.foo}'" which is caused by the exception above.

      One possibility is that I should write a data transfer object and put that in my stateful session bean, and when the user clicks "submit", the session bean will copy the info from the data transfer object into the persistent entity. But I thought the entire purpose of Seam was to get rid of such ugly coding styles. Any ideas?

      This is with Jboss 4.05 JEMS beta 3, Seam 1.1rc2, and all in Java 6.

      Any ideas would be appreciated. If I'm going to have to write a bunch of data transfers objects, I might as well not use Seam, right? But I don't see posts of other people doing that so I'm confused.


        • 1. Re: IllegalArgumentException: value of context variable is n
          None None Master

          Now I have figured out the major part of the problem here. I have an entity with an annotation like @Name("invoice") and then, in my dataTable, I have var="invoice", and that is bad bad bad because somehow it isn't being found or whatever. Moral of the story: Use separate names for the variables in your dataTable iterators as you have in your various contexts. It might work or it might cause a debugging nightmare. I need to get used to the namespaces of Seam. I do wish there were some good debugging utility that would let me see this stuff, but anyway.

          For the benefit of Google: I googled for this exception and noticed that I'm the first to mention it in any forum or anywhere, so anyone else who gets it will find this page and should look in their jsps for this. The exception is:

          Caused by: java.lang.IllegalArgumentException: value of context variable is not an instance of the component bound to the context variable:

          • 2. Re: IllegalArgumentException: value of context variable is n
            Maximiliano Carrizo Newbie

            Thank you. Your post help me very much !!