11 Replies Latest reply on Aug 22, 2007 8:24 AM by demetrio812

    selectOneMenu problem

    demetrio812

      Hi, I have a seam-gen app, in the edit form I inserted the following code:

      <s:decorate template="layout/edit.xhtml">
       <ui:define name="label">Stato</ui:define>
       <h:selectOneMenu id="stato" value="#{articoloHome.instance.statoArticolo}" required="true">
       <s:selectItems value="#{articoloHelper.getStatiArticolo(articoloHome.instance.tipologiaArticolo.id)}" var="stato" label="#{stato.descrizione}" noSelectionLabel="Seleziona lo stato..."/>
       <s:convertEntity />
       </h:selectOneMenu>
      </s:decorate>
      


      It call the getStatiArticolo function that is in articoloHelper (Seam POJO, Scope=CONVERSATION):

       private List<StatoArticolo> statiArticolo;
      
       public List<StatoArticolo> getStatiArticolo(int idTipologia)
       {
       if (statiArticolo==null) {
       statiArticolo = (List<StatoArticolo>) entityManager.createQuery(
       "from StatoArticolo sa WHERE sa.tipologiaArticolo.id = "+idTipologia+" ORDER BY sa.descrizione").getResultList();
       }
      
       return statiArticolo;
       }
      


      The menu and its items are rendered fine, the selected item works, but when I click on submit I got a strange error:



      java.lang.IllegalArgumentException: Unknown entity: com.novaware.unica.StatoArticolo_$$_javassist_5
      at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:185)
      at org.jboss.seam.persistence.EntityManagerProxy.find(EntityManagerProxy.java:85)
      at org.jboss.seam.framework.EntityIdentifier.find(EntityIdentifier.java:26)
      at org.jboss.seam.ui.converter.EntityConverterStore.get(EntityConverterStore.java:43)
      at org.jboss.seam.ui.converter.EntityConverter.getAsObject(EntityConverter.java:81)
      at org.jboss.seam.ui.converter.PrioritizableConverter.getAsObject(PrioritizableConverter.java:61)
      at org.jboss.seam.ui.converter.ConverterChain.getAsObject(ConverterChain.java:107)
      at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:152)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:197)
      at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:359)
      at javax.faces.component.UIInput.getConvertedValue(UIInput.java:934)
      at javax.faces.component.UIInput.validate(UIInput.java:860)
      at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
      at javax.faces.component.UIInput.processValidators(UIInput.java:666)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
      at javax.faces.component.UIForm.processValidators(UIForm.java:229)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
      at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
      at org.ajax4jsf.component.AjaxViewRoot.access$201(AjaxViewRoot.java:59)
      at org.ajax4jsf.component.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:321)
      at org.ajax4jsf.context.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:56)
      at org.ajax4jsf.context.AjaxContextImpl.invokeOnRegionOrRoot(AjaxContextImpl.java:171)
      at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:335)
      at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      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.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      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.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:595)
      Caused by: org.hibernate.MappingException: Unknown entity: com.novaware.unica.StatoArticolo_$$_javassist_5
      at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
      at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)
      at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
      at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
      at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
      at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:174)
      ... 66 more


      But StatoArticolo is a working entity (the form for example is showed well)...

      what can it be?

      Thanks

      Demetrio Filocamo

        • 1. Re: selectOneMenu problem
          demetrio812

          I also tried to do not use the method and use component definition in components.xml, if I don't use a value of the instance of articoloHome it works, like that:


           <framework:entity-query name="statoArticoliAll"
           entity-manager="#{entityManager}"
           ejbql="select sa from StatoArticolo sa WHERE sa.tipologiaArticolo.id=2"
           order="descrizione"
           scope="conversation">
           </framework:entity-query>
          


          I manually coded the "2" value of the id of tipologiaArticolo (that's wrong, I need dynamic value).

          In the right way I need it doesn't works and give me the same error:

           <framework:entity-query name="statoArticoliAll"
           entity-manager="#{entityManager}"
           ejbql="select sa from StatoArticolo sa"
           order="descrizione"
           scope="conversation">
           <framework:restrictions>
           <value>tipologiaArticolo = #{articoloHome.instance.tipologiaArticolo}</value>
           </framework:restrictions>
           </framework:entity-query>
          


          So I think the problem is in articoloHome (seam-gen generated class that extends EntityHome).

          Any ideas?

          Thanks!

          Demetrio Filocamo


          • 2. Re: selectOneMenu problem
            pmuir

            What version of Seam?

            • 3. Re: selectOneMenu problem
              demetrio812

              2.0B1, but it was a version of the july 9th...

              so I'm tring with the latest one but I got some problem (see also http://www.jboss.com/index.html?module=bb&op=viewtopic&t=116726)

              Thank for helping!

              Demetrio

              • 4. Re: selectOneMenu problem
                pmuir

                Please post the stack trace when you try this with current CVS.

                • 5. Re: selectOneMenu problem
                  demetrio812

                  I wanted to try with current CVS but I can't because it doesn't deploy coz of the other error and I need message bundles (the page that give me the error use them)...

                  So I'm waiting to solve the resourceBundle problem and then I will test it...

                  see the link I putted in the other post for further details...

                  thanks

                  Demetrio

                  • 6. Re: selectOneMenu problem
                    demetrio812

                    it seems the same bug of this one, isn't it?

                    http://jboss.com/index.html?module=bb&op=viewtopic&t=112337

                    demetrio

                    • 7. Re: selectOneMenu problem
                      demetrio812

                      I updated the project and it works now!!

                      Sorry for all the time you lost following me...

                      another little question:

                      I have a component in application scope:

                       <framework:entity-query name="linguaAll"
                       entity-manager="#{entityManager}"
                       ejbql="select lingua from Lingua lingua"
                       order="Descrizione"
                       scope="application">
                       </framework:entity-query>
                      


                      I putted in application because it doesn't change after startup...

                      If I use it in a selectOneMenu in this way:


                       <h:selectOneMenu id="lingua" value="#{articoloHome.instance.lingua}" required="true">
                       <s:selectItems value="#{linguaAll.resultList}" var="lingua" label="#{lingua.descrizione}"/>
                       <s:convertEntity />
                       </h:selectOneMenu>
                      


                      It give me the "Value is not valid" error...

                      if I put the component in conversation scope it works, but I thought that application scope was fine coz it is longer than conversation scope, where do I wrong? and if application scope is bad how can I do to do not reload from DB at every new conversation?

                      Thanks again!

                      Demetrio Filocamo

                      • 8. Re: selectOneMenu problem
                        pmuir

                        Read the SeamProblemsFAQ on the wiki

                        • 9. Re: selectOneMenu problem
                          demetrio812

                          Hi, thanks again...

                          I read it yesterday and I thought that giving that application scope is longer then conversation scope it would work...

                          now I read it again that line:


                          Ensure that you are in a long-running conversation that spans the both the select list creation and the submission of the form.


                          So maybe I must use the same conversation? (so the same JPA session?) is there a way to leave the component on application scope and then merge it in conversation scope?

                          other ideas on how to implement this?

                          Thanks

                          Demetrio Filocamo

                          • 10. Re: selectOneMenu problem
                            pmuir

                             

                            "demetrio812" wrote:
                            (so the same JPA session?)


                            Yes.

                            is there a way to leave the component on application scope and then merge it in conversation scope?


                            You have to implement equals()

                            • 11. Re: selectOneMenu problem
                              demetrio812

                              I see...

                              Thank you very much for your answers!!

                              Demetrio