13 Replies Latest reply on Oct 2, 2008 11:50 AM by Pete Muir

    Entities not annotated with @Name problem

    Marcell Newbie
      I am receiving a error using the s:convertEntity with entities not annotated with @Name. Do i have to annotate my entities with @Name to have this working?

      This is the stacktrace:

      19:20:31,802 ERROR [STDERR] 26/09/2008 19:20:31 com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/index.xhtml]
      org.jboss.seam.Entity$NotEntityException: Unable to establish name of entity class br.gov.tse.secad.modulos.endereco.Municipio_$$_javassist_4
              at org.jboss.seam.Entity.mergeAnnotationAndOrmXml(Entity.java:181)
              at org.jboss.seam.Entity.<init>(Entity.java:58)
              at org.jboss.seam.Entity.forClass(Entity.java:165)
              at org.jboss.seam.Entity.forBean(Entity.java:145)
              at org.jboss.seam.persistence.PersistenceProvider.getId(PersistenceProvider.java:64)
              at org.jboss.seam.persistence.HibernatePersistenceProvider.getId(HibernatePersistenceProvider.java:168)
              at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:13)
              at org.jboss.seam.ui.converter.entityConverter.EntityLoader.createIdentifier(EntityLoader.java:40)
              at org.jboss.seam.ui.converter.entityConverter.AbstractEntityLoader.put(AbstractEntityLoader.java:50)
              at sun.reflect.GeneratedMethodAccessor123.invoke(Unknown Source)
              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:21)
              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:31)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
              at org.jboss.seam.util.Work.workInTransaction(Work.java:41)
              at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              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:166)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at org.jboss.seam.ui.converter.entityConverter.EntityLoader_$$_javassist_2.put(EntityLoader_$$_javassist_2.java)
              at org.jboss.seam.ui.converter.EntityConverter.getAsString(EntityConverter.java:77)
              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.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:103)
              at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
              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 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: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: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:85)
              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:60)
              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:68)
              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:179)
              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(Thread.java:619)
        • 1. Re: Entities not annotated with @Name problem
          Rene Felgenträger Newbie

          In my opinione the @Name isnt a requirement for the EntityConverter to work properly.



          From your last entry of your stacktrace pointing at:


          org.jboss.seam.Entity$NotEntityException: Unable to establish name of entity class br.gov.tse.secad.modulos.endereco.Municipio_$$_javassist_4
                  at org.jboss.seam.Entity.mergeAnnotationAndOrmXml(Entity.java:181)



          I would check/do following:



          1. is the @Entity set

          2. is the equeals(Object o) overwritten

          3. make sure u either use XLM-Config or Annotations for ur entities. I dont know the exactly behevior in case of both. Normally, the XML-Config has higher precedence/priority in SEAM. Maybe any (optional?) ORM-XML-Config could cause some confusions what i guess from the merge-Exception of your stacktrace



          Greetings

          • 2. Re: Entities not annotated with @Name problem
            Marcell Newbie
            Hi,

            It is annotated with @Entity. equals and hashCode overridden with id equality. No XML config is been used and there isn't a "empty" xml.
            Any other thoughts for what is happening?
            I debug it and it really looks for a @Name config. Using Seam 2.0.2.SP1.

            []s
            • 3. Re: Entities not annotated with @Name problem
              Stuart Douglas Master

              Can you post the backing bean and XHTML code?

              • 4. Re: Entities not annotated with @Name problem
                Francisco Jose Peredo Noguez Master

                Rene Felgenträger wrote on Sep 27, 2008 06:31:


                In my opinione the @Name isnt a requirement for the EntityConverter to work properly.



                In my opinione the @Name is not just not a requirement, is plain wrong to use it in an @Entity




                From your last entry of your stacktrace pointing at:

                org.jboss.seam.Entity$NotEntityException: Unable to establish name of entity class br.gov.tse.secad.modulos.endereco.Municipio_$$_javassist_4
                        at org.jboss.seam.Entity.mergeAnnotationAndOrmXml(Entity.java:181)



                I would check/do following:


                1. is the @Entity set

                2. is the equeals(Object o) overwritten

                3. make sure u either use XLM-Config or Annotations for ur entities. I dont know the exactly behevior in case of both. Normally, the XML-Config has higher precedence/priority in SEAM. Maybe any (optional?) ORM-XML-Config could cause some confusions what i guess from the merge-Exception of your stacktrace



                Greetings



                Click HELP for text formatting instructions. Then edit this text and check the preview.

                • 5. Re: Entities not annotated with @Name problem
                  Marcell Newbie
                  My entities:

                  @Entity
                  @Table(name = "UF")
                  public class Uf extends BaseEntity {

                       @Column(name = "SGL_UF")
                       private String sigla;

                       @ManyToOne(fetch = FetchType.LAZY)
                       @JoinColumn(name = "COD_OBJETO_MUNIC_CAPITAL")
                       private Municipio capital;

                  ...
                  }

                  @Entity
                  @Table(name = "LOCALIDADE")
                  public class Municipio extends BaseEntity {

                       @Column(name = "NOM_LOCALIDADE")
                       private String nome;

                       @Column(name = "COD_LOCALIDADE_TSE")
                       private Integer codigo;

                       @Column(name = "SITUACAO")
                       private Integer situacao;

                       @ManyToOne(fetch = FetchType.EAGER)
                       @JoinColumn(name = "COD_OBJETO_UF")
                       private Uf uf;
                  ...
                  }

                  My action beans:

                  @Name("ufSelectAction")
                  @Scope(ScopeType.PAGE)
                  public class UfSelectAction extends BaseActionBean {

                       @In
                       private UfManager ufManager;

                       private Uf uf;

                       @SuppressWarnings("unused")
                       @Out(value = "selects_ufs", required = false)
                       private List<Uf> ufs;

                       @Factory("selects_ufs")
                       public void listUfs() {
                            ufs = ufManager.recuperaTodos();
                       }

                       public Uf getUf() {
                            return uf;
                       }

                       public void setUf(Uf uf) {
                            log.debug("Setando uf: #0", uf);
                            this.uf = uf;
                            events.raiseEvent("selects.uf", uf);
                            log.debug("Setado uf.");
                       }

                  }

                  @Name("municipioPorUfSelectAction")
                  @Scope(ScopeType.PAGE)
                  public class MunicipioPorUfSelectAction extends BaseActionBean {

                       private Uf uf;

                       private Municipio municipio;

                       @In
                       private MunicipioManager municipioManager;

                       @SuppressWarnings("unused")
                       @Out(value = "selects_municipiosPorUf", required = false)
                       private List<Municipio> municipios;

                       @Factory("selects_municipiosPorUf")
                       public void listMunicipios() {
                            if (uf != null) {
                                 municipios = municipioManager.recuperaPorUf(uf);
                            } else {
                                 municipios = Collections.emptyList();
                            }
                       }

                       @Observer(value = "selects.uf", create = false)
                       public void ufChanged(Uf uf) {
                            this.uf = uf;
                            listMunicipios();
                       }

                       public Municipio getMunicipio() {
                            return municipio;
                       }

                       public void setMunicipio(Municipio municipio) {
                            log.debug("Setando município: #0", municipio);
                            this.municipio = municipio;
                            events.raiseEvent("selects.municipio", municipio);
                            log.debug("Setado município.");
                       }

                  }

                  My selectOneMenu component:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:c="http://java.sun.com/jstl/core"
                       xmlns:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:s="http://jboss.com/products/seam/taglib"
                       xmlns:a4j="http://richfaces.org/a4j"
                       xmlns:rich="http://richfaces.org/rich"
                       xmlns:b="http://secad.tse.gov.br/baseweb">
                  <ui:component>
                       <s:decorate id="#{name}" styleClass="sc-formSelect"
                            rendered="#{b:def(rendered,true)}">
                            <h:outputLabel for="#{name}Select" value="#{b:def(label,name)}"
                                 accesskey="#{accesskey}">
                                 <c:if test="#{required}">
                                      <h:graphicImage value="#" styleClass="sc-required"
                                           title="Campo requerido" />
                                 </c:if>
                                 <s:message styleClass="sc-inputValida" />
                            </h:outputLabel>
                            <br />
                            <h:selectOneMenu id="#{name}Select" value="#{value}"
                                 required="#{required}" onchange="#{onchange}" title="#{title}"
                                 style="#{style}" styleClass="#{styleClass}"
                                 readonly="#{b:def(readonly,false)}" disabled="#{readonly}">
                                 <c:choose>
                                      <c:when test="#{b:def(showNoSelection,true)}">
                                           <s:selectItems value="#{items}" var="item" label="#{itemsLabel}"
                                                noSelectionLabel="#{b:def(noSelectionLabel, messages['select.noValue'])}" />
                                      </c:when>
                                      <c:otherwise>
                                           <s:selectItems value="#{items}" var="item" label="#{itemsLabel}" />
                                      </c:otherwise>
                                 </c:choose>
                                 <c:if test="#{itemsType eq 'entity'}">
                                      <s:convertEntity />
                                 </c:if>
                                 <c:if test="#{itemsType eq 'enum'}">
                                      <s:convertEnum />
                                 </c:if>
                                 <c:if test="#{not empty reRender}">
                                      <a4j:support event="onchange" eventsQueue="onchangeEventsQueue"
                                           reRender="#{reRender}" limitToList="true"
                                           ajaxSingle="true" bypassUpdates="false"
                                           ignoreDupResponses="true" onsubmit="#{onSubmit}"
                                           oncomplete="#{oncomplete}" immediate="false"
                                           action="#{logAction.debug('Ajax Update')}">
                                      </a4j:support>
                                 </c:if>
                                 <ui:insert />
                            </h:selectOneMenu>
                       </s:decorate>
                  </ui:component>
                  </html>

                  My xhtml page:

                  <html xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:c="http://java.sun.com/jstl/core"
                       xmlns:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:s="http://jboss.com/products/seam/taglib"
                       xmlns:a4j="http://richfaces.org/a4j"
                       xmlns:rich="http://richfaces.org/rich"
                       xmlns:b="http://secad.tse.gov.br/baseweb">
                  <b:layout>
                       <b:selectOneMenu name="ufField" items="#{selects_ufs}"
                            value="#{ufSelectAction.uf}" itemsLabel="#{item.sigla}"
                            itemsType="entity"
                            reRender="ufField, zonaPorUfField, municipioPorUfField" />

                       <b:selectOneMenu name="municipioPorUfField"
                            items="#{selects_municipiosPorUf}"
                            value="#{municipioPorUfSelectAction.municipio}"
                            itemsLabel="#{item.nome}" itemsType="entity" />
                  </b:layout>
                  </html>
                  • 7. Re: Entities not annotated with @Name problem
                    Marcell Newbie
                    @MappedSuperclass
                    public abstract class BaseEntity implements Serializable {

                         @Id
                         @Column(name = "COD_OBJETO")
                         protected String id;

                         public String getId() {
                              return id;
                         }

                         public void setId(String id) {
                              this.id = id;
                         }

                         @Override
                         public int hashCode() {
                              final int prime = 31;
                              int result = 1;
                              result = prime * result + ((id == null) ? 0 : id.hashCode());
                              return result;
                         }

                         @Override
                         public boolean equals(Object obj) {
                              if (this == obj)
                                   return true;
                              if (obj == null || !(obj instanceof BaseEntity))
                                   return false;
                              final BaseEntity other = (BaseEntity) obj;
                              if (id == null) {
                                   if (other.id != null)
                                        return false;
                              } else if (!id.equals(other.id))
                                   return false;
                              return true;
                         }

                         /**
                          * Constructs a <code>String</code> with all attributes in name = value
                          * format.
                          *
                          * @return a <code>String</code> representation of this object.
                          */
                         public String toString() {
                              final String TAB = "; ";
                              StringBuilder retValue = new StringBuilder();
                              retValue.append("BaseEntity ( ").append("id = ").append(this.id).append(TAB).append(" )");
                              return retValue.toString();
                         }

                         private static final long serialVersionUID = 1L;

                    }
                    • 8. Re: Entities not annotated with @Name problem
                      Diego Coronel Apprentice

                      Hi Marcell,


                      Whats your seam version ? i got same problem using 2.0.2 and 2.0.3 seam versions. It works fine in 2.0.1.GA and i dont know with 2.1.X versions.

                      • 9. Re: Entities not annotated with @Name problem
                        Marcell Newbie

                        Using 2.0.2.SP1. I'll retrofit to 2.0.1.GA and post results.

                        • 10. Re: Entities not annotated with @Name problem
                          Pete Muir Master

                          Marcell, please report this in JIRA with an example I can use to reproduce.

                          • 11. Re: Entities not annotated with @Name problem
                            Sandeep Shenoy Newbie
                            I faced the same problem with convertEntity,

                            Setting the fk to fetch = FetchType.EAGER , instead of Lazy fixed it for me.

                            @ManyToOne(fetch = FetchType.EAGER)
                            @JoinColumn(name = "COD_OBJETO_MUNIC_CAPITAL")
                            private Municipio capital;

                            Hope this will work for u too.
                            • 12. Re: Entities not annotated with @Name problem
                              Marcell Newbie

                              I detected the problem but I don't know if it is a bug or not, and if it is a bug it is a JSF or Seam.


                              Here is the code that do not work:


                              @Name("municipioPorUfSelectAction")
                              @Scope(ScopeType.PAGE)
                              public class MunicipioPorUfSelectAction extends BaseActionBean {
                              
                               private Uf uf;
                              
                               private Municipio municipio;
                              
                               @In
                               private MunicipioManager municipioManager;
                              
                               @SuppressWarnings("unused")
                               @Out(value = "selects_municipiosPorUf", required = false)
                               private List<Municipio> municipios;
                              
                               @Factory("selects_municipiosPorUf")
                               public void listMunicipios() {
                                if (uf != null) {
                                 municipios = municipioManager.recuperaPorUf(uf);
                                } else {
                                 municipios = Collections.emptyList();
                                }
                               }
                              
                               @Observer(value = "selects.uf", create = false)
                               public void ufChanged(Uf uf) {
                                this.uf = uf;
                                listMunicipios();
                               }
                              
                               public Municipio getMunicipio() {
                                return municipio;
                               }
                              
                               public void setMunicipio(Municipio municipio) {
                                log.debug("Setando município: #0", municipio);
                                this.municipio = municipio;
                                events.raiseEvent("selects.municipio", municipio);
                                log.debug("Setado município.");
                               }
                              
                              }



                              Here is after the fix:


                              @Name("municipioPorUfSelectAction")
                              @Scope(ScopeType.PAGE)
                              public class MunicipioPorUfSelectAction extends BaseActionBean {
                              
                               private Uf uf;
                              
                               private Municipio municipio;
                              
                               @In
                               private MunicipioManager municipioManager;
                              
                               @Factory("selects_municipiosPorUf")
                               public List<Municipio> listMunicipios() {
                                if (uf != null) {
                                 return municipioManager.recuperaPorUf(uf);
                                } else {
                                 return Collections.emptyList();
                                }
                               }
                              
                               @Observer(value = "selects.uf", create = false)
                               public void ufChanged(Uf uf) {
                                this.uf = uf;
                                Contexts.getPageContext().remove("selects_municipiosPorUf");
                               }
                              
                               public Municipio getMunicipio() {
                                return municipio;
                               }
                              
                               public void setMunicipio(Municipio municipio) {
                                log.debug("Setando município: #0", municipio);
                                this.municipio = municipio;
                                events.raiseEvent("selects.municipio", municipio);
                                log.debug("Setado município.");
                               }
                              
                              }



                              As you see the problem is in a conflict of @Out updating the List.

                              • 13. Re: Entities not annotated with @Name problem
                                Pete Muir Master

                                Please, still file the bug.