title: Error while deployment - Unable to build EntityManagerFactory
body: <p>There are previous post regarding this issue, but that didn't resolve the issue.</p>
  
  <p>When I deploy application war, I am getting the following error</p>
  
  <pre><code>Invocation of init method failed; nested exception is javax.persistence.
  PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory 
  at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:133)
  at 
  oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun
  (OC4JDeployerRunnable.java:52)
  at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run
  (DeployerRunnable.java:81)
  at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run
  (ReleasableResourcePooledExecutor.java:298)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Not sure how to resolve this issue.</p>
  
  <p>ApplicationContext.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd"
  &gt;
      &lt;!-- Data Source Declaration --&gt;    
      &lt;bean id="DataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName" value="jdbc/scottDS"/&gt;   
      &lt;/bean&gt;
  
      &lt;context:component-scan base-package="net.test" /&gt;
      &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/&gt;
      &lt;bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="DataSource" /&gt;
          &lt;property name="packagesToScan" value="net.test" /&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                  &lt;property name="showSql" value="true" /&gt;
                  &lt;property name="generateDdl" value="false" /&gt;
                  &lt;property name="databasePlatform" value="${jdbc.dialectClass}" /&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" /&gt;  
      &lt;!-- Transaction Config --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;          
      &lt;context:annotation-config/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Entity classes</p>
  
  <p>Emp </p>
  
  <pre><code>@Entity
  @Table(name = "EMP"
  )
  @XmlRootElement
  public class Emp implements java.io.Serializable {
  
      private short empno;
      private Dept dept;
      private String ename;
      private String job;
      private Short mgr;
      private Date hiredate;
      private BigDecimal sal;
      private BigDecimal comm;
  
      public Emp() {
      }
  
      public Emp(short empno) {
          this.empno = empno;
      }
  
      public Emp(short empno, Dept dept, String ename, String job, Short mgr, Date hiredate, 
              BigDecimal sal, BigDecimal comm) {
          this.empno = empno;
          this.dept = dept;
          this.ename = ename;
          this.job = job;
          this.mgr = mgr;
          this.hiredate = hiredate;
          this.sal = sal;
          this.comm = comm;
      }
  
      @Id
      @Column(name = "EMPNO", unique = true, nullable = false, precision = 4, scale = 0)
      public short getEmpno() {
          return this.empno;
      }
  
      public void setEmpno(short empno) {
          this.empno = empno;
      }
  
  @ManyToOne
      @JoinColumn(name="DEPTNO")
      public Dept getDept() {
          return this.dept;
      }
  
      public void setDept(Dept dept) {
          this.dept = dept;
      }
      @Column(name = "ENAME", length = 10)
      public String getEname() {
          return this.ename;
      }
  
      public void setEname(String ename) {
          this.ename = ename;
      }
  
      @Column(name = "JOB", length = 9)
      public String getJob() {
          return this.job;
      }
  
      public void setJob(String job) {
          this.job = job;
      }
  
      @Column(name="MGR", precision=4, scale=0)
      public Short getMgr() {
          return this.mgr;
      }
  
      public void setMgr(Short mgr) {
          this.mgr = mgr;
      }
      @Temporal(TemporalType.DATE)
      @Column(name="HIREDATE", length=7)
      public Date getHiredate() {
          return this.hiredate;
      }
  
      public void setHiredate(Date hiredate) {
          this.hiredate = hiredate;
      }
      @Column(name="SAL", precision=7)
      public BigDecimal getSal() {
          return this.sal;
      }
  
      public void setSal(BigDecimal sal) {
          this.sal = sal;
      }
  
  
      @Column(name="COMM", precision=7)
      public BigDecimal getComm() {
          return this.comm;
      }
  
      public void setComm(BigDecimal comm) {
          this.comm = comm;
      }
  }
  </code></pre>
  
  <p>Dept</p>
  
  <pre><code>@Entity
  @Table(name="DEPT"
  )@XmlRootElement
  public class Dept  implements java.io.Serializable {
  
  
       private byte deptno;
       private String dname;
       private String loc;
       private Set emps = new HashSet(0);
  
      public Dept() {
      }
  
  
      public Dept(byte deptno) {
          this.deptno = deptno;
      }
      public Dept(byte deptno, String dname, String loc,Set emps) {
         this.deptno = deptno;
         this.dname = dname;
         this.loc = loc;
         this.emps = emps;
      }
  
       @Id 
      @Column(name="DEPTNO", unique=true, nullable=false, precision=2, scale=0)
      public byte getDeptno() {
          return this.deptno;
      }
  
      public void setDeptno(byte deptno) {
          this.deptno = deptno;
      }
  
  
      @Column(name="DNAME", length=14)
      public String getDname() {
          return this.dname;
      }
  
      public void setDname(String dname) {
          this.dname = dname;
      }
  
  
      @Column(name="LOC", length=13)
      public String getLoc() {
          return this.loc;
      }
  
      public void setLoc(String loc) {
          this.loc = loc;
      }
  
  @OneToMany(mappedBy="dept")
  public Set&lt;Emp&gt; getEmps() {
      return this.emps;
  }
  
      public void setEmps(Set emps) {
          this.emps = emps;
      }
  
  
  
  
  }
  </code></pre>
  
  <p>Update </p>
  
  <p>persistence.xml</p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0"&gt;
          &lt;persistence-unit name="default" transaction-type="RESOURCE_LOCAL"&gt;
              &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
              &lt;class&gt;net.test.entity.Emp&lt;/class&gt;
              &lt;class&gt;net.test.entity.Dept&lt;/class&gt;
              &lt;properties&gt;
                  &lt;property name="toplink.logging.level" value="FINE"/&gt;
                  &lt;property name="toplink.jdbc.driver" value="oracle.jdbc.OracleDriver"/&gt;  
                  &lt;property name="toplink.jdbc.url" value="jdbc:oracle:thin:@serverdb:1521:devp"/&gt; 
                  &lt;property name="toplink.jdbc.password" value="scott"/&gt; 
                  &lt;property name="toplink.jdbc.user" value="tiger"/&gt;
              &lt;/properties&gt;
          &lt;/persistence-unit&gt;
      &lt;/persistence&gt;
  </code></pre>
  
  <p>Modified applicationContext.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd"
  &gt;
      &lt;context:component-scan base-package="net.test" /&gt;
  
     &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="default" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="generateDdl" value="false" /&gt;
              &lt;property name="showSql" value="true" /&gt;
              &lt;property name="databasePlatform" value="org.hibernate.dialect.OracleDialect" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
      &lt;!-- Transaction Config --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;          
      &lt;context:annotation-config/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Update 2</p>
  
  <p>Modified persistence.xml</p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0"&gt;
      &lt;persistence-unit name="default" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
          &lt;class&gt;net.test.entity.Emp&lt;/class&gt;
          &lt;class&gt;net.test.entity.Dept&lt;/class&gt;
          &lt;properties&gt;
          &lt;property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver" /&gt;
          &lt;property name="hibernate.connection.url" value="jdbc:oracle:thin:@serverdb:1521:DEVP" /&gt;
          &lt;property name="hibernate.connection.username" value="scott" /&gt;
          &lt;property name="hibernate.connection.password" value="tiger" /&gt;
          &lt;property name="hibernate.show_sql" value="true" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>