0 Replies Latest reply on May 8, 2009 2:54 PM by Tathagat Tathagat

    convertentity and TransientObjectException

    Tathagat Tathagat Newbie

      Hi there.


      seam-version: 2.1.1.GA
      rich-faces-version: 3.2.0.GA


      I am having a problem similar to http://www.seamframework.org/Community/TransientObjectExceptionUnderSeam210SP1.


      I have a class staticDataAction in APPLICATION scope. In this class I load all my static data to be used in different pages.


      I have a registration page which is backed by a bean in PAGE scope. Here I have a dropdown to select the sex of the user.


      <h:selectOneMenu value="#{register.newUser.sex}" required="true" id="sex" label="Sex">
       <s:selectItems value="#{staticData.sex}" var="sex" label="#{sex.name}" noSelectionLabel="--Please Select--" />
       <s:convertEntity />
      </h:selectOneMenu>



      I see the drop down fine, but when I click on the save button I get the following exception


      org.hibernate.TransientObjectException: The instance was not associated with this session
           at org.hibernate.impl.SessionImpl.getIdentifier(SessionImpl.java:1375)
           at org.jboss.seam.persistence.HibernateSessionProxy.getIdentifier(HibernateSessionProxy.java:236)
           at org.jboss.seam.framework.HibernateEntityIdentifier.<init>(HibernateEntityIdentifier.java:13)
           at org.jboss.seam.ui.HibernateEntityLoader.createIdentifier(HibernateEntityLoader.java:28)
           at org.jboss.seam.ui.AbstractEntityLoader.put(AbstractEntityLoader.java:46)
           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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:95)
           at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
           at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:89)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
           at org.jboss.seam.ui.HibernateEntityLoader_$$_javassist_3.put(HibernateEntityLoader_$$_javassist_3.java)
           at org.jboss.seam.ui.EntityConverter.getAsString(EntityConverter.java:65)
           at org.jboss.seam.ui.converter.PrioritizableConverter.getAsString(PrioritizableConverter.java:67)
           at org.jboss.seam.ui.converter.ConverterChain.getAsString(ConverterChain.java:126)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:448)
           at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:480)
           at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:772)
           at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:832)
           at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:280)
           at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
           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:837)
           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:146)
           at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
           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:189)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
           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.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
           at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
           at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164)
           at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
           at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
           at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:406)
           at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           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:147)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
           at org.ajax4jsf.Filter.doFilter(Filter.java:175)
           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.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
           at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
           at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
           at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
           at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
           at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
           at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
           at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
           at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
           at org.mortbay.jetty.Server.handle(Server.java:324)
           at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
           at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
           at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
           at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
           at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
           at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
           at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)




      According to the link I post earlier, my scopes are fine (As I am inserting something from APPLICATION to PAGE scope so it should be available).
      The difference in my case is that I am not using EJB but I am using simple hibernate.


      Here are my components.xml and hibernate.cfg.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:drools="http://jboss.com/products/seam/drools"
        xmlns:web="http://jboss.com/products/seam/web"
        xmlns:mail="http://jboss.com/products/seam/mail"
        xmlns:transaction="http://jboss.com/products/seam/transaction"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:spring="http://jboss.com/products/seam/spring"
        xmlns:international="http://jboss.com/products/seam/international"
        xmlns:ui="http://jboss.com/products/seam/ui"
        xsi:schemaLocation=
            "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
             http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
             http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
             http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd
             http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
             http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
             http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
             http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
             http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.0.xsd
             http://jboss.com/products/seam/international http://jboss.com/products/seam/international-2.0.xsd">
      
           <core:init />
           
           <security:identity authenticate-method="#{authenticator.authenticate}"/>
      
           <persistence:hibernate-session-factory name="hibernateSessionFactory"/>
      
           <persistence:managed-hibernate-session name="managedHibernateSession"
                                  session-factory="#{hibernateSessionFactory}"/>
           
           <transaction:hibernate-transaction session="#{managedHibernateSession}"/>
           
           <ui:hibernate-entity-loader session="#{managedHibernateSession}" />
           
           <event type="org.jboss.seam.security.notLoggedIn">
               <action execute="#{redirect.captureCurrentView}"/>
           </event>
           <event type="org.jboss.seam.security.postAuthenticate">
               <action execute="#{redirect.returnToCapturedView}"/>
           </event>
      
      </components>



      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      
      <hibernate-configuration>
          <session-factory>
               <!--<property name="show_sql">true</property>-->
                <property name="hibernate.dialect">${hibernate.dialect}</property>
              <property name="hibernate.connection.driver_class">${jdbc.driverClassName}</property>
                 <property name="hibernate.connection.url">${jdbc.url}</property>
                <property name="hibernate.connection.username">${jdbc.username}</property>
                <property name="hibernate.connection.password">${jdbc.password}</property>
                <property name="hibernate.connection.pool_size">10</property>
                <property name="hibernate.hbm2ddl.auto">update</property>
      
               <mapping class="com.algolog.app.rupee2india.staticdata.Country"/>
               <mapping class="com.algolog.app.rupee2india.staticdata.Sex"/>
               
               <mapping class="com.algolog.app.rupee2india.security.User"/>
               <mapping class="com.algolog.app.rupee2india.security.Role"/>
               
               <mapping class="com.algolog.app.rupee2india.client.Address"/>
               <mapping class="com.algolog.app.rupee2india.client.BankAccount"/>
      
          </session-factory>
      </hibernate-configuration>



      Any clues why I am getting this exception? Any help is highly appreciated.
      Thanks in advance!


      Cheers