5 Replies Latest reply on Nov 15, 2005 6:42 AM by nusa

    "Cannot get value for expression" error

    nusa

      Hi,

      I have the following jsp page :

      <h:dataTable value="#{projectUpdate.findAll}" var="row" rows="10"
       binding="#{dataAction.table}" >
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="ProjectID" />
       </f:facet>
       <h:outputText value="#{row.projectId}" />
       </h:column>
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="ProjectName" />
       </f:facet>
       <h:inputText value="#{row.projectName}" />
       </h:column>
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="Descriptions" />
       </f:facet>
       <h:inputText value="#{row.descriptions}" />
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="SelectItem" />
       </f:facet>
       <h:commandButton value="Update" action="#{projectUpdate.markForEdition}" />
       </h:column>
      
      </h:dataTable>
      


      and these 2 beans :
      @Name("dataAction")
      @Scope(EVENT)
      public class DataAction {
      
       private static Logger log = Logger.getLogger(DataAction.class);
      
       private UIData table;
      
       public UIData getTable() {
       return table;
       }
      
       public void setTable(UIData table) {
       this.table = table;
       }
      
      }
      


      @Intercept(InterceptionType.ALWAYS)
      @Name("projectUpdate")
      public class ProjectUpdate implements Serializable {
      
       private static Logger log = Logger.getLogger(ProjectUpdate.class);
      
       @In
       @Out
       private Project project;
      
       private List<Project> listProject;
      
       @In(create=true)
       private Session hibernateSession;
      
       public ProjectUpdate() {
       log.info("=== Constructor ...");
       }
      
       public List<Project> getFindAll() {
       log.info("=== getFindAll ... ");
       if (listProject == null)
       buildListProject();
       return listProject;
       }
      
       public void setFindAll(List<Project> prj) {
       this.listProject = prj;
       }
      
       @SuppressWarnings("unchecked")
       public void buildListProject() {
       log.info("=== buildListProject ... ");
       List<Project> list = null;
       try {
       list = hibernateSession.createCriteria(Project.class)
       .addOrder(Order.asc("projectName"))
       .list();
       log.info("=== buildListProject has : " + list.size());
       } catch (HibernateException ex) {
       log.info("HibernateException raised : " + ex.toString());
       }
       setFindAll(list);
       }
      
       @IfInvalid(outcome=REDISPLAY)
       public String markForEdition() {
       log.info("=== markForEdition ...");
      
       log.info("=== get dataAction ...");
       DataAction data = (DataAction)Contexts.getEventContext().get("dataAction");
      
       UIData table = data.getTable();
      
       if ( table.isRowAvailable() ) {
       project = (Project) table.getRowData();
       log.info("=== Attempting to update a row : " + project.toString());
      
       hibernateSession.saveOrUpdate(project);
       return "success";
       } else {
       log.info("=== Couldn't find row !!!");
       }
      
       return null;
       }
      
      }
      


      When that JSP page get rendered, the list of projects is displayed properly :
      14:53:03,192 INFO [example.action.ProjectUpdate] === Constructor ...
      14:53:03,192 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:53:03,192 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolved name to seam component
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: project
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: project.component
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in conversation context: hibernateSession
      14:53:03,202 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: hibernateSession.component
      14:53:03,202 INFO [example.action.ProjectUpdate] === getFindAll ...
      14:53:03,202 INFO [example.action.ProjectUpdate] === buildListProject ...
      14:53:03,232 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
      14:53:03,232 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
      14:53:03,232 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
      14:53:03,232 DEBUG [org.hibernate.SQL]
       select
       this_.projectId as projectId0_0_,
       this_.version as version0_0_,
       this_.descriptions as descript3_0_0_,
       this_.projectName as projectN4_0_0_
       from
       Project this_
       order by
       this_.projectName asc
      14:53:03,232 INFO [STDOUT] Hibernate:
       select
       this_.projectId as projectId0_0_,
       this_.version as version0_0_,
       this_.descriptions as descript3_0_0_,
       this_.projectName as projectN4_0_0_
       from
       Project this_
       order by
       this_.projectName asc
      14:53:03,232 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
      14:53:03,232 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
      14:53:03,242 DEBUG [org.hibernate.loader.Loader] processing result set
      


      But when I click on the 'Update' button, I got the following error :
      14:56:45,112 DEBUG [org.jboss.seam.contexts.Lifecycle] >>> Begin web request
      14:56:45,112 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,112 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.manager
      14:56:45,112 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: dataAction
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: dataAction.component
      14:56:45,153 DEBUG [org.jboss.seam.Component] instantiating Seam component: dataAction
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: dataAction.component
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolved name to seam component
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: dataAction
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: dataAction
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: dataAction.component
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolved name to seam component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: dataAction.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 DEBUG [org.jboss.seam.core.Manager] No stored conversation
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.init
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.init.component
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] After restore view, conversation context: ConversationContext(3)
      14:56:45,153 DEBUG [org.jboss.seam.contexts.BusinessProcessContext] Created BusinessProcessContext
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: projectUpdate
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:56:45,153 DEBUG [org.jboss.seam.Component] instantiating Seam component: projectUpdate
      14:56:45,153 INFO [example.action.ProjectUpdate] === Constructor ...
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:56:45,153 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolved name to seam component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,153 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,153 ERROR [org.jboss.seam.servlet.SeamExceptionFilter] uncaught exception handled by Seam: Cannot get value for expression '#{projectUpdate.findAll}'
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Lifecycle] After render response, destroying contexts
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Lifecycle] flushing busines process context
      14:56:45,163 DEBUG [org.jboss.seam.contexts.BusinessProcessContext] no in-memory state to flush to jBPM context
      14:56:45,163 DEBUG [org.jboss.seam.contexts.BusinessProcessContext] no jBPM context to which to flush
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Lifecycle] destroying event context
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.core.manager
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: dataAction.component
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] destroying: dataAction
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: projectUpdate.component
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] destroying: projectUpdate
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Lifecycle] destroying conversation context
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Lifecycle] flushing server-side conversation context
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
      14:56:45,163 DEBUG [org.jboss.seam.contexts.Lifecycle] <<< End web request
      14:56:45,163 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/SeamTest].[faces]] Servlet.service() for servlet faces threw exception
      javax.faces.el.EvaluationException: Cannot get value for expression '#{projectUpdate.findAll}'
       at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:399)
       at javax.faces.component.UIData.getValue(UIData.java:779)
       at javax.faces.component.UIData.createDataModel(UIData.java:545)
       at javax.faces.component.UIData.getDataModel(UIData.java:534)
      ...
      


      Can someone help me where that error coming from ?

      Thanks.

        • 1. Re:
          nusa

          Hmmm,

          If I amend the ProjectUpdate :

          @In(create=true)
          


          I don't have that error, but the update does not commited in the database, even the log says commited :
          11:27:32,341 INFO [example.action.ProjectUpdate] === markForEdition ...
          11:27:32,341 INFO [example.action.ProjectUpdate] === get dataAction ...
          11:27:32,341 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: dataAction.component
          11:27:32,341 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
          11:27:32,341 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
          11:27:32,341 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
          11:27:32,341 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
          11:27:32,341 INFO [example.action.ProjectUpdate] === Attempting to update a row : Project ( p4 0 Project4 Project4 by baa )
          11:27:32,351 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] persistent instance of: example.model.Project
          11:27:32,351 DEBUG [org.hibernate.event.def.DefaultMergeEventListener] ignoring persistent instance
          11:27:32,351 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: project.component
          11:27:32,351 DEBUG [org.jboss.seam.contexts.Contexts] found in event context: org.jboss.seam.core.manager
          11:27:32,351 DEBUG [org.jboss.seam.contexts.Contexts] found in application context: org.jboss.seam.core.manager.component
          11:27:32,351 DEBUG [org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener] committing transaction
          


          Aaarrrrgghhhh, this drives me crazy ...
          Could someone give me a suggestion, please ?

          Thanks.

          • 2. Re:
            nusa

            Any taker please ?
            How do you guys manage to update a row ?

            I really need your help / suggestions.

            Thanks

            • 3. Re:
              nusa

              Any taker please ?
              How do you guys manage to update a row ?

              I'm stuck ... I really need your help / suggestions.

              Thanks

              • 4. Re:
                cajboss

                Please let me know if you have managed to figure out the solution?

                thanks

                • 5. Re:
                  nusa

                  I try to, but still without success.

                  I have my hibernate config file defined as :

                  <?xml version="1.0" encoding="UTF-8"?>
                  
                  <!DOCTYPE hibernate-configuration PUBLIC
                   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
                  
                  <hibernate-configuration>
                  
                   <session-factory name="hibernateSession">
                  
                   <!-- JNDI configuration for HSQL -->
                   <property name="connection.datasource">java:DefaultDS</property>
                   <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
                  
                   <!-- Common configuration -->
                   <property name="format_sql">true</property>
                   <property name="show_sql">true</property>
                  
                   <!-- Plugin ConnectionProvider -->
                   <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
                  
                   <property name="transaction.flush_before_completion">true</property>
                   <property name="connection.release_mode">after_statement</property>
                  
                   <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
                   <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
                  
                   <mapping class="example.model.Project"/>
                  
                   </session-factory>
                  
                  </hibernate-configuration>
                  


                  I tried various combination of @In and @Out for the variable 'project', but it came with various answer.
                  If I use just @In, I got an error : "In attribute requires value for component: project".
                  If I use just @Out, I got : "Out attribute requires value for component: project"
                  If I use either @In(create=true) or @Out(required=false), it did not commited in the database.

                  How about you ? Any idea ?

                  Thanks