14 Replies Latest reply on Jun 12, 2012 8:44 PM by marianokm

    HHH015011: Unable to locate static metamodel field

    klejs

      Hi,

       

      I started porting an JEE5 application from JBoss 4.2 to JBoss 7.1.1 today. Everything has gone quite nice but one thing; when I am deploying the application I get an error log saying something like:

       

      HHH015011: Unable to locate static metamodel field : com.myapp.MyEntity_#mMyField

       

      The class is annotated with @MappedSuperclass and looks something like this:

       

      @MappedSuperclass

      public class EternalEntity {

       

         @Basic

         @Column(name="active")

         private String mMyField;

        

         public String getMyField() {

            return mMyField;

         }

       

         public void setMyField(String myField) {

            mMyField = myField;

         }

      }

       

      Everything works ok in JBoss 4.2. Has anyone seen this error before and knows how to solve it?

       

      Thanks in advance

       

      /KA

        • 1. Re: HHH015011: Unable to locate static metamodel field
          marianokm

          Hi Everyone,

          Exacty the same thing is happening to me.

          • 2. Re: HHH015011: Unable to locate static metamodel field
            marianokm

            Moreover,

            Also this happens with @Embeddables objects mapped within @Entities.

            • 3. Re: HHH015011: Unable to locate static metamodel field
              smarlow

              Please attach the entire exception callstack for this.

              • 4. Re: HHH015011: Unable to locate static metamodel field
                smarlow

                Please attach the  exception callstack for the @Embeddables case also.

                • 5. Re: HHH015011: Unable to locate static metamodel field
                  marianokm

                  Hi, Scott

                  These are the issues we are facing with criteria/metamodel APIs and Jboss-as-7.1.0

                   

                  As you can see from the attached example (zip file), we are extending an @Entity (TaxAgent) from a @MappedSuperclass (Agent)

                  Agent has an @Embedded attribute (document), and this generates two errors:

                   

                  1. When deploying there "Unable to locate static metamodel field" errors. Note that this errors act at two levels, first the document field cannot be found in TaxAgent_ but also, the documentType field cannot be found inside our embeddable, Document_.

                   

                  2. When trying to create a path expression from the root object (taxAgent) to TaxAgent_.document an exception is thrown (which is below).

                   

                  3. Also, we've found this:

                  https://hibernate.onjira.com/browse/HHH-5024 (which is similar but a different hierarchy @Embeddable extending a @MappedSuperclass)

                   

                  4. At "deploy" time the logger error message as below:

                  17:15:01,452 ERROR [MetadataContext] Unable to locate static metamodel field : agents.TaxAgent_#document

                  17:15:01,457 ERROR [MetadataContext] Unable to locate static metamodel field : stuff.Document_#documentType

                   

                  5. At query time:

                  public final List<TaxAgent> getList(final String description)

                  {

                      List<TaxAgent> taxAgentList = null;

                      try

                      {

                          final CriteriaBuilder cb = em.getCriteriaBuilder();

                          final CriteriaQuery<TaxAgent> cq = cb.createQuery(TaxAgent.class);

                          final Root<TaxAgent> taxAgent = cq.from(TaxAgent.class);

                   

                          // <- This is the exception line: at service.manager.ejb.TaxAgentManagerEJB.getList(TaxAgentManagerEJB.java:61) [:]

                          final Path<Document> document = taxAgent.get(TaxAgent_.document);

                   

                          //    final Path<Document> document = taxAgent.get("document"); // <- This works (just in case you were asking)

                          final Path<String> documentNumber = document.get(Document_.documentNumber);

                          final StringBuilder sb = new StringBuilder();

                   

                          sb.append("%").append(description.trim().replaceAll(" ", "%")).append("%");

                          cq.where(cb.like(cb.upper(cb.trim(documentNumber)), sb.toString().toUpperCase()));

                   

                          // Gets data.

                          final TypedQuery<T> tq = em.createQuery(cq);

                          taxAgentList = tq.getResultList();

                      }

                      catch (Throwable t)

                      {

                          throw new EJBException(t.getMessage());

                      }

                      return taxAgentList;

                  }

                   

                  6. Query execution:

                  2011-11-11 11:24:49,330 ERROR [com.ebizlink.pandora2.web.component.BaseComponent] (http-127.0.0.1-8080-1) null: javax.ejb.EJBException

                      at service.manager.ejb.TaxAgentManagerEJB.getList(TaxAgentManagerEJB.java:61) [:]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_20]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_20]

                      at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_20]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62) [:1.1.3]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_20]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_20]

                      at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_20]

                      at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:74) [:1.1.3]

                      at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_11985797.invoke(InvocationContextInterceptor_z_fillMethod_11985797.java)

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:90) [:1.1.3]

                      at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_11985797.invoke(InvocationContextInterceptor_z_setup_11985797.java)

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.async.impl.interceptor.AsynchronousServerInterceptor.invoke(AsynchronousServerInterceptor.java:128) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) [:1.0.3]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.core.context.SessionInvocationContextAdapter.proceed(SessionInvocationContextAdapter.java:95) [:1.7.17]

                      at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:247) [:0.0.1]

                      at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:349) [:0.0.1]

                      at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:209) [:0.0.1]

                      at org.jboss.ejb3.tx2.aop.CMTTxInterceptorWrapper.invoke(CMTTxInterceptorWrapper.java:52) [:0.0.1]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) [:1.0.0.GA]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) [:1.0.3]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:182) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:323) [:1.7.17]

                      at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:380) [:1.7.17]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_20]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_20]

                      at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_20]

                      at org.jboss.ejb3.proxy.impl.handler.session.SessionLocalProxyInvocationHandler$LocalContainerInvocation.invokeTarget(SessionLocalProxyInvocationHandler.java:184) [:1.0.11]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.async.impl.interceptor.AsynchronousClientInterceptor.invoke(AsynchronousClientInterceptor.java:143) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.proxy.impl.handler.session.SessionLocalProxyInvocationHandler$LocalInvokableContextHandler.invoke(SessionLocalProxyInvocationHandler.java:159) [:1.0.11]

                      at $Proxy288.invoke(Unknown Source)    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:185) [:1.0.11]

                      at $Proxy274.getList(Unknown Source)    at com.ebizlink.pandora2.web.component.form.BaseAutoCompleteComponent.getList(BaseAutoCompleteComponent.java:73) [:]

                      at com.ebizlink.pandora2.web.component.form.BaseAutoCompleteComponent.complete(BaseAutoCompleteComponent.java:59) [:]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_20]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_20]

                      at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_20]

                      at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [:6.0.0.Final]

                      at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [:6.0.0.Final]

                      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) [:2.0.3-]

                      at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeResults(AutoCompleteRenderer.java:78) [:]

                      at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeEnd(AutoCompleteRenderer.java:60) [:]

                      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879) [:2.0.3-]

                      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) [:2.0.3-]

                      at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:479) [:2.0.3-]

                      at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:175) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1476) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at javax.faces.component.UIForm.visitTree(UIForm.java:331) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) [:2.0.3-]

                      at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:361) [:2.0.3-]

                      at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:282) [:2.0.3-]

                      at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:179) [:2.0.3-]

                      at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:968) [:2.0.3-]

                      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643) [:2.0.3-]

                      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:378) [:2.0.3-]

                      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127) [:2.0.3-]

                      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117) [:2.0.3-]

                      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-]

                      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135) [:2.0.3-]

                      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309) [:2.0.3-]

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

                      at com.ebizlink.adonis.common.ui.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:31) [:]

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

                      at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) [:]

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]

                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]

                      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]

                      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:593) [:6.0.0.Final]

                      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]

                      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]

                      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]

                      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]

                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]

                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]

                      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]

                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]

                      at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]

                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]

                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]

                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]

                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]

                      at java.lang.Thread.run(Thread.java:636) [:1.6.0_20]

                   

                  2011-11-11 11:24:49,369 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-127.0.0.1-8080-1) java.lang.NullPointerException

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package agents;

                   

                  import java.io.Serializable;

                  import javax.persistence.Embedded;

                  import javax.persistence.GeneratedValue;

                  import javax.persistence.GenerationType;

                  import javax.persistence.Id;

                  import javax.persistence.MappedSuperclass;

                  import javax.persistence.SequenceGenerator;

                  import stuff.Document;

                   

                  @MappedSuperclass

                  @SuppressWarnings("serial")

                  public abstract class Agent implements Serializable

                  {

                      @Id

                      @SequenceGenerator(name = "id", sequenceName = "agent_seq")

                      @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")

                      private Long agentID;

                   

                      @Embedded

                      private Document document;

                   

                      /**

                       */

                      protected Agent(Document document)

                      {

                          this.agentID = 0l;

                          this.document = document;

                      }

                   

                      // getters, setters...

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package agents;

                   

                  import javax.persistence.Entity;

                  import javax.persistence.Table;

                  import javax.persistence.UniqueConstraint;

                  import stuff.Document;

                   

                  @Entity

                  @Table(name = "taxagent", uniqueConstraints = @UniqueConstraint(columnNames = {"documentTypeID", "documentNumber"}))

                  @SuppressWarnings("serial")

                  public final class TaxAgent extends Agent

                  {

                      /**

                       */

                      protected TaxAgent(Document document)

                      {

                          super(document);

                      }

                   

                      /**

                       */

                      public TaxAgent()

                      {

                          this(null);

                      }

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package stuff;

                   

                  import java.io.Serializable;

                  import javax.persistence.Column;

                  import javax.persistence.Embeddable;

                  import javax.persistence.FetchType;

                  import javax.persistence.JoinColumn;

                  import javax.persistence.ManyToOne;

                   

                  @Embeddable

                  @SuppressWarnings("serial")

                  public final class Document implements Serializable

                  {

                      @ManyToOne(fetch = FetchType.EAGER)

                      @JoinColumn(name = "documentTypeID")

                      private DocumentType documentType;

                   

                      @Column(length = 20)

                      private String documentNumber;

                   

                      /**

                       */

                      public Document(DocumentType documentType, String documentNumber)

                      {

                          this.documentType = documentType;

                          this.documentNumber = documentNumber;

                      }

                   

                      /**

                       */

                      public Document()

                      {

                          this(null, "");

                      }

                   

                      // getters, setters...

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package stuff;

                   

                  import javax.persistence.Cacheable;

                  import javax.persistence.Column;

                  import javax.persistence.Entity;

                  import javax.persistence.GeneratedValue;

                  import javax.persistence.GenerationType;

                  import javax.persistence.Id;

                  import javax.persistence.SequenceGenerator;

                  import javax.persistence.Table;

                   

                  @Entity

                  @Table(name = "documenttype")

                  @Cacheable(value = true)

                  @SuppressWarnings("serial")

                  public final class DocumentType implements Serializable

                  {

                      @Id

                      @SequenceGenerator(name = "id", sequenceName = "documenttype_seq")

                      @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")

                      private Long documentTypeID;

                   

                      @Column(length = 50, unique = true)

                      private String description;

                   

                      /**

                       */

                      public DocumentType(String description)

                      {

                          this.documentTypeID = 0l;

                          this.description = description;

                      }

                   

                      /**

                       */

                      public DocumentType()

                      {

                          this("");

                      }

                   

                      // getters, setters...

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package agents;

                   

                  import stuff.Document;

                  import javax.persistence.metamodel.SingularAttribute;

                  import javax.persistence.metamodel.StaticMetamodel;

                   

                  @StaticMetamodel(Agent.class)

                  public abstract class Agent_ {

                   

                      public static volatile SingularAttribute<Agent, Document> document;

                      public static volatile SingularAttribute<Agent, Long> agentID;

                   

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package agents;

                   

                  import javax.persistence.metamodel.ListAttribute;

                  import javax.persistence.metamodel.SingularAttribute;

                  import javax.persistence.metamodel.StaticMetamodel;

                   

                  @StaticMetamodel(TaxAgent.class)

                  public abstract class TaxAgent_ extends agents.Agent_ {

                   

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package stuff;

                   

                  import javax.persistence.metamodel.SingularAttribute;

                  import javax.persistence.metamodel.StaticMetamodel;

                   

                  @StaticMetamodel(Document.class)

                  public abstract class Document_ {

                   

                      public static volatile SingularAttribute<Document, DocumentType> documentType;

                      public static volatile SingularAttribute<Document, String> documentNumber;

                   

                  }

                   

                  ===============================================================================

                  sample code

                  ===============================================================================

                  package stuff;

                   

                  import javax.persistence.metamodel.SingularAttribute;

                  import javax.persistence.metamodel.StaticMetamodel;

                   

                  @StaticMetamodel(DocumentType.class)

                  public abstract class DocumentType_ {

                   

                      public static volatile SingularAttribute<DocumentType, String> description;

                      public static volatile SingularAttribute<DocumentType, Long> documentTypeID;

                   

                  }

                  • 6. Re: HHH015011: Unable to locate static metamodel field
                    smarlow

                    Hi Mariano,

                     

                    Did you attach the wrong exception callstack above?  That looks like a null pointer exception instead of an "Unable to locate static metamodel field" error.

                     

                    Also, see if you can reproduce with the nightly AS7 build.

                     

                    Scott

                    • 7. Re: HHH015011: Unable to locate static metamodel field
                      marianokm

                      Hi Scott,

                      I've attached both:

                       

                      1. Error al deploy time (see point 4 about "Unable to locate static metamodel field")

                      2. Error at execution/query time (see point 5,6)

                       

                      Kind Regards !

                      • 8. Re: HHH015011: Unable to locate static metamodel field
                        smarlow

                        So, the "Unable to locate static metamodel field" appears during deployment?  Could you attach or paste some output from deployment that shows that.

                        • 9. Re: HHH015011: Unable to locate static metamodel field
                          marianokm

                          Thoughts,

                           

                          About errors at deploy time (static metamodel fields not found), seems like the app server is complaining when either:

                          a. Class "B" extends class "A" and class "A" is defined as @MappedSuperClass

                          b. Class "B" embed a property of type "X" where "X" is defined as @Embeddable.

                           

                          No matter with that, the application server log these errors (at deploy time) but the EAR application keep up and running.

                           

                          Therefore, the thing is:

                          a. We want to build jpa2 criterias queries filtering by those missing fields (see attached code: Agent, TaxAgent, Document, DocumentType and also see sample query code at point 5)

                          b. If path expresions are built over static metamodel properties the query throws a NPE (and makes sense since at deploy time the appserver has signaled that some static metamodel fields were missing)

                          c. If path expresions are built over "strings" (bypassing static metamodel properties) the query is executed without errors (but this is just a fix/workaround and should not be used in this way)

                           

                          Hope this help in order to describe the issue we are facing.

                           

                          Let me know your thoughts,

                          Regards !

                          • 10. Re: HHH015011: Unable to locate static metamodel field
                            marianokm

                            Of course,

                            17:15:01,452 ERROR [MetadataContext] Unable to locate static metamodel field : agents.TaxAgent_#document

                            17:15:01,457 ERROR [MetadataContext] Unable to locate static metamodel field : stuff.Document_#documentType

                            • 11. Re: HHH015011: Unable to locate static metamodel field
                              smarlow

                              I'm not sure of the cause.  I asked about this problem and there are a few issues (some related to HHH-5024). 

                               

                              From a recent IRC discussion about this:

                              Part of the problem is that there are just lots of incorrect mappings that crop up there.  People trying to override mapping information incorrectly.  More defensive checking is really what is needed there.

                               

                              I suspect that it might be easier for you to help contribute a Hibernate patch/fix to add the defensive error checking. 

                              • 12. Re: HHH015011: Unable to locate static metamodel field
                                marianokm

                                Hi Scott,

                                Sorry for the delay.

                                Thank you very much for the suggestion, im affraid this could be the only way, the thing is that issue is opened since 2010.

                                Regards!

                                • 13. Re: HHH015011: Unable to locate static metamodel field
                                  smarlow

                                  Hi Mariano,

                                   

                                  If you are interested in helping with a Hibernate patch, you could subscribe to https://lists.jboss.org/mailman/listinfo/hibernate-dev and ask for guidance on where the code changes should go.

                                   

                                  The short term plans for further metamodel development are discussion in an IRC meeting here (from #hibernate-dev on freenode).

                                   

                                  Scott

                                  • 14. Re: HHH015011: Unable to locate static metamodel field
                                    marianokm

                                    Thanks again Scott,

                                    I'll follow the hibernate dev list as soon as possible.

                                    cheers!