title: Hibernate as JPA Provider in JavaEE application
body: <p>I am working on a JavaEE6 application using Netbeans 7, Glassfish 3.1.</p>
  
  <p>The application works fine and is getting deployed on GlassFish. But the issue is that when i am setting Hibernate as the provider in the persistence.xml, i get the following exception:</p>
  
  <pre><code>INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  SEVERE: Exception while preparing the app
  SEVERE: org/dom4j/Element
  java.lang.NoClassDefFoundError: org/dom4j/Element
     at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
     at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:205)
     at org.glassfish.persistence.jpa.PersistenceUnitLoader.&lt;init&gt;(PersistenceUnitLoader.java:119)
     at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:213)
     at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
     at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:220)
     at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:166)
     at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:870)
     at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
     at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:364)
     at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:208)
     at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
     at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
     at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
     at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
     at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
     at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
     at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:243)
     at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:135)
     at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
     at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
     at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
  </code></pre>
  
  <p>Here is my persistence.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0" 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 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
    &lt;persistence-unit name="EntAppEJB-ejbPU" transaction-type="JTA"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;jta-data-source&gt;schema&lt;/jta-data-source&gt;
      &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
       &lt;properties&gt;
        &lt;property name="hibernate.search.default.indexBase" value="/tmp"/&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>These are the jar files which i have included in the project:</p>
  
  <pre><code>hibernate3.jar
  hibernate-jpa-2.0-api-1.0.0.Final.jar
  antlr-2.7.6.jar
  commons-collections-3.1.jar
  dom4j-1.6.1.jar
  javassist-3.12.0.GA.jar
  jta-1.1.jar
  slf4j-api-1.6.1
  slf4j-simple-1.6.1
  hibernate-search-3.4.0.Final.jar
  commons-lang-2.4
  hibernate-commons-annotations-3.2.0.Final.jar
  hibernate-core-3.6.3.Final.jar
  lucene-core-3.1.0.jar
  </code></pre>
  
  <p>What am i missing here? Any suggestions are most welcome.</p>