title: Spring data JPA java.lang.IllegalArgumentException: Not an entity
body: <p>I have created spring data JPA sample project. I used eclips for this. There are two projects, one is domain object project which has only annotated entity classes.  Other project is actual spring data jpa project and it has a dependency for the project one. Actually it gets domain project entity classes via maven dependency.</p>
  
  <p>Project 1 : hrm-domain</p>
  
  <p>Entity class :</p>
  
  <pre><code>package com.hrm.ws.data.domain;
  
  import javax.persistence.Basic;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Inheritance;
  import javax.persistence.InheritanceType;
  import javax.persistence.Table;
  
  
  
  @Entity(name = "Employee")
  @Table(name = "employee")
  @Inheritance(strategy = InheritanceType.JOINED)
  public class Employee {
  
      protected long id;
  
      protected String firstName;
  
      protected String lastName;
  
      /**
       * Gets the value of the id property.
       * 
       */
      @Id
      @Column(name = "id", scale = 0)
      @GeneratedValue(strategy = GenerationType.AUTO)
      public long getId() {
          return id;
      }
  </code></pre>
  
  <p>Project 2 : hrm-ws-service</p>
  
  <p>persistance-context.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  
         xsi:schemaLocation="http://www.springframework.org/schema/beans 
                             http://www.springframework.org/schema/beans/spring-beans.xsd
                             http://www.springframework.org/schema/data/jpa
                             http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&gt;
  
  
          &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
              &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt;
              &lt;property name="url" value="${jdbc.url}"/&gt;
              &lt;property name="username" value="${jdbc.username}"/&gt;
              &lt;property name="password" value="${jdbc.password}"/&gt;
          &lt;/bean&gt;
  
          &lt;jpa:repositories base-package="com.hrm.ws.data.repository" /&gt;
  
  
          &lt;bean id="employeeDao" class="com.hrm.ws.data.repository.EmployeeRepositoryImpl"/&gt;      
  
  
          &lt;bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager"&gt;
  
                &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
                &lt;property name="jpaDialect"&gt;
                  &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt;
                &lt;/property&gt;
  
          &lt;/bean&gt;
  
          &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
  
                &lt;property name="dataSource" ref="dataSource" /&gt;
  
                &lt;property name="jpaVendorAdapter"&gt;
                  &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                    &lt;property name="generateDdl" value="${jdbc.generateDdl}" /&gt;
                    &lt;property name="showSql" value="${jdbc.showSql}"/&gt;
                  &lt;/bean&gt;
                &lt;/property&gt;
                &lt;property name="persistenceUnitName" value="jpa.sample" /&gt;
  
          &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>So the setup for my packages is as follows:    </p>
  
  <p>src/main/java - contains the spring repository</p>
  
  <p>src/main/resources - contains application context</p>
  
  <p>src/test/java - contains unit tests</p>
  
  <p>And dependency for the project 1 (hrm-domain) </p>
  
  <p>My problem is when I run this project I am getting error as follows: </p>
  
  <pre><code>... 38 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Not an entity: class com.hrm.ws.data.domain.Employee
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1429)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
      ... 40 more
  
  
  **Caused by: java.lang.IllegalArgumentException: Not an entity: class** com.hrm.ws.data.domain.Employee
      at org.hibernate.ejb.metamodel.MetamodelImpl.entity(MetamodelImpl.java:160)
      at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.&lt;init&gt;(JpaMetamodelEntityInformation.java:52)
      at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:61)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:83)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:66)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:146)
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:120)
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:39)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
      ... 48 more
  </code></pre>
  
  <p>I am wondering about this issue, because when I put domain object (Employee.java)  in my spring project it self rather separate jar it works fine. This issue only happens it gives as a separate jar.  If any one has experience about  scenario like that please give me a help.  </p>