2 Replies Latest reply on Sep 18, 2007 5:12 AM by fhh

    the TransientObjectException with <s:convertEntity />

    Filippo De Luca Newbie

      Hello dear Seam users.

      I have this problem: when display a selectOneMenu, whit a list of Entity, i obtain this error: "The instance was not associated with this session".

      It is generated by convertEntity.

      this is my page

      <h:selectOneMenu value="#{editUtente.gruppoToAdd}" >
       <s:selectItems value="#{editUtente.availableGruppi}" var="gruppo" label="#{gruppo.nome}" noSelectionLabel="Please Select..." />
       <s:convertEntity />
      </h:selectOneMenu>
      <s:button id="addGruppo" value="Aggiungi" action="#{editUtente.addGruppo}"/>
      


      and this my action
      
      @Name("editUtente")
      @Stateful
      public class EditUtenteActionBean implements EditUtenteActionLocal {
      
       public static final String MODE_CREATE = "create";
      
       public static final String MODE_UPDATE = "update";
      
       @Logger
       private Log log;
      
       @In
       private FacesMessages facesMessages;
      
       @In
       private Events events;
      
       private AccountManager accountManager;
      
       // From Spring
       @In("#{passwordEncoder}")
       private PasswordEncoder passwordEncoder;
      
       @Out
       private Utente utente;
      
       @RequestParameter("id")
       private Long userId;
      
       private String mode;
      
       private String password;
      
       private String passwordVerify;
      
       private Gruppo gruppoToAdd;
      
       /** Default constructor */
       public EditUtenteActionBean() {
       // Empty
       }
      
      
       /**
       * @param accountManager
       * the accountManager to set
       */
       @EJB
       public void setAccountManagerLocal(AccountManagerLocal accountManager) {
       this.accountManager = accountManager;
       }
      
       ...
      
       /**
       * @return the availableGruppi
       */
       public List<Gruppo> getAvailableGruppi() {
       return accountManager.listGruppi();
       }
      
       ...
      



      This is my stack trace
      org.hibernate.TransientObjectException: The instance was not associated with this session
       at org.hibernate.impl.SessionImpl.getIdentifier(SessionImpl.java:1375)
       at org.hibernate.search.impl.FullTextSessionImpl.getIdentifier(FullTextSessionImpl.java:331)
       at org.jboss.seam.persistence.HibernateSessionProxy.getIdentifier(HibernateSessionProxy.java:205)
       at org.jboss.seam.persistence.HibernatePersistenceProvider.getId(HibernatePersistenceProvider.java:114)
       at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:15)
       at org.jboss.seam.ui.converter.EntityConverterStore.put(EntityConverterStore.java:60)
       at org.jboss.seam.ui.converter.EntityConverter.getAsString(EntityConverter.java:69)
       at org.jboss.seam.ui.converter.PrioritizableConverter.getAsString(PrioritizableConverter.java:67)
       at org.jboss.seam.ui.converter.ConverterChain.getAsString(ConverterChain.java:123)
       at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:469)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:502)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
       at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
       at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
       at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
       at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
       at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:94)
       at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:189)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:184)
       at org.ajax4jsf.framework.renderer.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       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.MultipartFilter.doFilter(MultipartFilter.java:87)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
       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:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       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:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      


      Anyone can help me?

      Tanks Filippo

        • 1. Re: the TransientObjectException with <s:convertEntity />
          Filippo De Luca Newbie

          So, I discovered some problem:

          The view presentation appened in a different hibernate session. if i use a stateless bean to load the selectItems entities, using the EntityManager component of Seam, it work fine.


          But I have my Daos Stateless EJB, and if i use them i receive same error.

          Anyone can help me?


          This is the correct code:

          @Name("gruppoService")
          @Scope(ScopeType.STATELESS)
          @Stateless
          public class GruppoServiceBean implements GruppoServiceLocal {
          
           private AccountManager accountManager;
          
           /**
           *
           */
           public GruppoServiceBean() {
           // Empty
           }
          
           @EJB
           public void setAccountManagerLocal(AccountManagerLocal accountManagerLocal){
           this.accountManager = accountManagerLocal;
           }
          
           @SuppressWarnings("unchecked")
           public List<Gruppo> listGruppi(){
           Query query = entityManager.createQuery("from Gruppo as gruppo");
          
           return (List<Gruppo>)query.getResultList();
          
           }
          
          }
          


          While this code cause Error. The AccountManager is a Stateless EJB.
          @Name("gruppoService")
          @Scope(ScopeType.STATELESS)
          @Stateless
          public class GruppoServiceBean implements GruppoServiceLocal {
          
           private AccountManager accountManager;
          
           /**
           *
           */
           public GruppoServiceBean() {
           // Empty
           }
          
           @EJB
           public void setAccountManagerLocal(AccountManagerLocal accountManagerLocal){
           this.accountManager = accountManagerLocal;
           }
          
           @SuppressWarnings("unchecked")
           public List<Gruppo> listGruppi(){
           return accountManager.listGruppi();
           }
          
          }
          


          I've set this property on persistence.xml:


          and my components.xml:
          <persistence:managed-persistence-context name="entityManager"
          auto-create="true"
          persistence-unit-jndi-name="java:/EntityManagerFactories/siccr" />


          It's right?

          • 2. Re: the TransientObjectException with <s:convertEntity />
            fhh Expert

            Two, possible reasons:

            1.) Your entity was not retrieved by the same session as convertentity uses and you are using Seam 2.0 Beta1. If so upgrade to a nightly build.

            2.) The groups in the list have never been persisted.

            Regards

            Felix