4 Replies Latest reply on Mar 19, 2009 3:39 AM by Thomas Robert

    TransientObjectException under Seam 2.1.0 SP1

    Tamas Malatinszki Newbie

      Hi all,


      I'm using a h:selectOneMenu with an s:convertEntity this way:



      <h:selectOneMenu id="sourceListBox" value="#{hireAction.selectedSource}">
        <s:selectItems id="sourceItems" value="#{sourceList}" var="sss" label="#{sss.source}" itemValue="#{sss}"/>
        <s:convertEntity/>
      </h:selectOneMenu>
                          
      <a4j:commandButton value="#{messages.add}" action="#{hireAction.addSelected}" reRender="hirePanel"/>
      



      If I'm clicking on the commandbutton I would like to get the selected entity in the selectedSource variable. It's working fine, the s:converEntity converts the selected item without any problem (see the first row in error log), but after it I get a really weird error message:



      16:10:54,124 INFO  [HireActionImpl] SELECTED SOURCE IS: 90:GWH (so it is working fine)
      16:10:54,171 ERROR [STDERR] Nov 11, 2008 4:10:54 PM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/pages/main.xhtml]
      javax.faces.FacesException: org.hibernate.TransientObjectException: The instance was not associated with this session
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:725)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:543)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Unknown Source)
      



      I configured my components.xml and hibernate.cfg.xml according to the latest Seam reference pdf, so I don't understand what should be the problem.


      components.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                      xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:ui="http://jboss.com/products/seam/ui"
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
                                           http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
                                           http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                                           http://jboss.com/products/seam/ui http://jboss.com/products/seam/ui-2.1.xsd
                                           http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
                                           http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
                                           http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd">
       
        <core:init transaction-management-enabled="true" debug="true" jndi-pattern="@jndiPattern@"/> 
        <core:manager conversation-timeout="120000" 
                      concurrent-request-timeout="500"
                      conversation-id-parameter="cid"/>
      
        <transaction:ejb-transaction/>
        <persistence:hibernate-session-factory name="hibernateSessionFactory"/>
        <persistence:managed-hibernate-session name="drsession" auto-create="true" session-factory="#{hibernateSessionFactory}"/>
        <transaction:hibernate-transaction session="#{drsession}"/>
        <ui:hibernate-entity-loader session="#{drsession}"/>
      
      </components>
      



      hibernate.cfg.xml


      <?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="hibernateSessionFactory">
              <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
              <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
               <property name="transaction.flush_before_completion">true</property>
               <property name="connection.release_mode">after_statement</property>
      
                <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
                  <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
                  <property name="connection.datasource">java:/directreportsDatasource</property>
      
                  <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
                  <property name="hibernate.show_sql">true</property>
                  <property name="hibernate.hbm2ddl.auto">validate</property>
                  <property name="hibernate.format_sql">true</property>
                  <property name="hibernate.default_schema">hct</property>
                  
                  <mapping class="com.flex.directreports.entity.Source"/>
          </session-factory>
      </hibernate-configuration>
      



      Here is the related part of my SFSB:



      @Startup
      @Stateful
      @Name("hireAction")
      @Scope(ScopeType.SESSION)
      public class HireActionImpl implements HireAction {
      
           @In
           private Session drsession;
           
           @DataModel
           private List<Source> sourceList;
           
           private Source selectedSource;
      
           @Logger Log log;
           
           public void addSelected(){
                log.info("SELECTED SOURCE IS: "+selectedSource.getSourceId()+":"+selectedSource.getSource());
           }
      



      I'm using JBoss 4.2.3GA and Seam 2.1.0 SP1.


      Many thanks,
      Tamas