title: java.lang.IllegalArgumentException: Named query not found.(Entity Manager not creating NamedQuery)
body: <p>I am using hibernate 4.1.5.Final and Spring 3.1.2 Release and Jboss 7.1 . I have written all named queries in a class with @NamedQuery annotation but entity manager not creating named query . i am posting the stacktrace and context.xml </p>
  
  <pre><code>  09:58:49,695 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) java.lang.IllegalArgumentException: Named query not found: validateLoginHash
      09:58:49,770 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:642)
      09:58:49,772 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
      09:58:49,774 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      09:58:49,777 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at java.lang.reflect.Method.invoke(Method.java:597)
      09:58:49,779 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
  
      09:58:49,782 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at $Proxy30.createNamedQuery(Unknown Source)
  
      09:58:49,784 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
  
      09:58:49,785 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  
      09:58:49,788 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at java.lang.reflect.Method.invoke(Method.java:597)
  
      09:58:49,790 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
  
      09:58:49,793 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)   at $Proxy30.createNamedQuery(Unknown Source)
  </code></pre>
  
  <p><strong>ApplicationContext.xml</strong></p>
  
  <pre><code>&lt;bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/&gt; 
      &lt;bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
  
  
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="jpaDialect" ref="jpaDialect"/&gt;
          &lt;property name="packagesToScan" value="com.project.entities"/&gt; 
  
  
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;          
                  &lt;property name="showSql" value="false" /&gt;
                  &lt;property name="generateDdl" value="false" /&gt;
                  &lt;property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" /&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
  
  &lt;!--        &lt;property name="persistenceUnitName" value="Project" /&gt; --&gt;
          &lt;property name="persistenceXmlLocation" value="classpath:META-INF/jpa-persistence.xml"/&gt; 
  
          &lt;property name="loadTimeWeaver"&gt;
              &lt;bean
                  class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /&gt;
          &lt;/property&gt;
  
      &lt;/bean&gt;
  
       &lt;bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName" value="java:jboss/datasources/MySqlDS"/&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p><strong>jpa-persistence.xml</strong></p>
  
  <pre><code>&lt;persistence&gt;
      &lt;persistence-unit name="Project" transaction-type="RESOURCE_LOCAL" &gt;
  
  
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
           &lt;non-jta-data-source&gt;java:jboss/datasources/MySqlDS&lt;/non-jta-data-source&gt;
  &lt;!--         &lt;properties&gt;  --&gt;
  &lt;!--           &lt;property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" /&gt;        --&gt;
  &lt;!--           &lt;/properties&gt;          --&gt;
  
      &lt;/persistence-unit&gt;
  
  &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>DBNamedQuery.java</strong></p>
  
  <pre><code>@Entity
  @NamedQueries( {
  
  @NamedQuery(name = ... , query = ... ),
  @NamedQuery(name = ..., query = ...),
  
  .....More named queries
  
  })
  
  public class DBNamedQuery {
  
  
  }
  </code></pre>