1 Reply Latest reply on Aug 4, 2011 3:07 AM by Luca Cavagnoli

    s:convertEntity --> IllegalArgumentException: Id and clazz must not be null (With managed entities)

    Luca Cavagnoli Newbie

      Hello!


      (I know a similar post about this exception was written, but it regarded unmanaged entities. In this case, it's about managed entities.)


      I'm developing a simple application following the examples in Seam in Action.
      I created the pages to create Roles and Users.
      The Role creation page works perfectly, roles are correctly persisted.
      In the User creation page, a h:selectManyListbox is used to select the user's roles:


      <s:decorate id="rolesField" template="layout/edit.xhtml">
          <ui:define name="label">Roles</ui:define>
          <h:selectManyListbox value="#{userHome.instance.roles}" id="rolesSOM">
              <s:selectItems id="rolesSI" var="role" value="#{roleList.resultList}" label="#{role.name}" noSelectionLabel="Please Select..."/>
              <s:convertEntity/>
          </h:selectManyListbox>
      </s:decorate>
      



      The rendering of the page results in the following exception to be thrown:


      javax.faces.FacesException: Exception while calling encodeEnd on component : {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /user.xhtml][Class: javax.faces.component.html.HtmlForm,Id: userForm][Class: org.richfaces.component.html.HtmlPanel,Id: j_id11][Class: org.jboss.seam.ui.component.html.HtmlDecorate,Id: rolesField][Class: org.jboss.seam.ui.component.html.HtmlValidateAll,Id: j_id80][Class: javax.faces.component.html.HtmlSelectManyListbox,Id: rolesSOM]}
           at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:652)
           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:27)
           at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:627)
           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:152)
           at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:627)
           at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
           at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
           at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:200)
           at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:195)
           at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:627)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:250)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:257)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
           at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
           at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:187)
           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: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:206)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
           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:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
           at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.IllegalArgumentException: Id and clazz must not be null
           at org.jboss.seam.framework.Identifier.<init>(Identifier.java:18)
           at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:13)
           at org.jboss.seam.ui.JpaEntityLoader.createIdentifier(JpaEntityLoader.java:29)
           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:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
           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:97)
           at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
           at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
           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.JpaEntityLoader_$$_javassist_seam_6.put(JpaEntityLoader_$$_javassist_seam_6.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 org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:648)
           at org.apache.myfaces.shared_impl.renderkit.RendererUtils.internalSubmittedOrSelectedValuesAsSet(RendererUtils.java:709)
           at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getSelectedValuesAsSet(RendererUtils.java:615)
           at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(HtmlRendererUtils.java:354)
           at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:337)
           at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderListbox(HtmlRendererUtils.java:283)
           at org.apache.myfaces.shared_impl.renderkit.html.HtmlListboxRendererBase.encodeEnd(HtmlListboxRendererBase.java:51)
           at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:649)
           ... 60 more
      



      My entity manager's name is the default entityManager.


      Here are some exerpts of the entity classes:


      @Entity
      public class Role implements Serializable {
      
           private static final long serialVersionUID = 1522632604999710539L;
      
           @Id
           @GeneratedValue
           private Long id;
           @Version
           private Integer version;
           @NotNull
           @Length(max = 20)
           @Column(unique = true)
           private String name;
      



      @Entity
      public class User implements Serializable {
      
           private static final long serialVersionUID = 3644834165028836251L;
      
           @NotNull
           private String confirmPassword;
           @Id
           @GeneratedValue
           private Long id;
           @NotNull
           private String name;
           @NotNull
           private String surname;
           @NotNull
           private String password;
           // Uni-directional
           @ManyToMany
           @JoinTable
           private List<Role> roles;
           @NotNull
           @Column(unique = true)
           private String username;
           @Version
           private Integer version;
      



      I thank in advance who will help me!