0 Replies Latest reply on Nov 3, 2012 9:12 AM by mali_karabulut

    Seam 2.2, alternate JPA provider instead of hibernate

    mali_karabulut

      Hi,

      I posted this question in another forum however couldn't get an answer yet. I hope someone here can help me about this issue:

       

      Hi all,

      I want to use another JPA provider instead of hibernate in my seam 2.2 + jboss 4.2.3 J2EE 5.0 web(crud) application.

      I followed the instructions given in both seam 2.2 reference and some online resources such as http://in.relation.to/Bloggers/UsingAnAlternateJPAProviderWithSeam

      However I keep getting  "java.lang.RuntimeException: java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil" error.

      I think this is due to class path error that my server runtime can not find the alternative JPA jar file. I tried placing the [otherjpa].jar file in the server/default/deploy directory and also server/default/lib directory but with no success.

      What am I doing wrong? Should I follow any special jar deployment procedure on my jboss 4.2.3 app. server?

      I'll appreciate any help.

       

      Here are some details about my configuration:

       

      1. persistence.xml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!-- Persistence deployment descriptor for dev profile -->

      <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">

       

      <persistence-unit name="pu">

          <!--<provider>org.hibernate.ejb.HibernatePersistence</provider>-->

                <provider>org.batoo.jpa.core.BatooPersistenceProvider</provider>

                <jta-data-source>java:/myProjectDatasource</jta-data-source>

       

        <properties>

                           <property name="org.batoo.jpa.ddl" value="NONE" />

       

          <!--

         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>

         <property name="hibernate.show_sql" value="false"/>

         <property name="hibernate.format_sql" value="true"/>

         <property name="jboss.entity.manager.factory.jndi.name" value="java:myProjectEntityManagerFactory"/>

          -->

       

                </properties>

      </persistence-unit>

      </persistence>

       

       

       

      2. components.xml (partially)

      <component name="org.jboss.seam.persistence.persistenceProvider"

           class="tr.com.bilisim.shgm.util.CustomBatooPersistenceProvider">

      </component>

       

      3.CustomBatooPersistenceProvider.java

      package tr.com.bilisim.shgm.util;

       

      import javax.persistence.EntityManager;

       

      import org.jboss.seam.ScopeType;

      import org.jboss.seam.annotations.Install;

      import org.jboss.seam.annotations.Scope;

      import org.jboss.seam.annotations.intercept.BypassInterceptors;

      import org.jboss.seam.persistence.PersistenceProvider;

       

      //@Name("org.jboss.seam.persistence.persistenceProvider")

      @Scope(ScopeType.STATELESS)

      @BypassInterceptors

      @Install(precedence= 10/*FRAMEWORK*/ , classDependencies={"javax.persistence.EntityManager"})

      public class CustomBatooPersistenceProvider extends PersistenceProvider {

       

         @Override

         public void setFlushModeManual(EntityManager entityManager) {

            // no-op

                   System.err.println("CustomBatooPersistenceProvider-setFlushModeManual");

         }

      }

       

       

      4. JPA jar file placed in: (not sure where to place this jar file though)

           jboss-4.2.3.GA\server\default\deploy\batoo-jpa-0.1.6.jar

           jboss-4.2.3.GA\server\default\lib\batoo-jpa-0.1.6.jar

       

      and also in my ear project (even tried 'Make Deployable' option for this jar file in eclipse)

           myproject-ear\Ear Content\lib\batoo-jpa-0.1.6.jar

       

      PS: My project was perfectly working with hibernate configuration, datasource definitions etc. (No problem at all. with previous configuration)

       

       

      Thanks,

      M.Ali