8 Replies Latest reply on Jan 30, 2013 9:05 AM by Scott Marlow

    How to use Batoo with AS7

    floflo floflo Newbie

      Hello,

       

      I Add the Batoo module:

       

      Create the directory $JBOSS_HOME/modules/org/batoo/persistence/main and drop the batoo-jpa-2.0.1.0-RTM.jar into it.

      Then create module.xml and copy the below into it.

       

      <module xmlns="urn:jboss:module:1.1" name="org.batoo.persistence">

          <resources>

              <resource-root path="batoo-jpa-2.0.1.0-RTM.jar"/>

              <!-- Insert resources here -->

          </resources>

      <dependencies>

        <module name="asm.asm"/>

        <module name="javax.api"/>

        <module name="javax.persistence.api"/>

        <module name="javax.transaction.api"/>

        <module name="javax.validation.api"/>

        <module name="javax.xml.bind.api"/>

        <module name="org.antlr"/>

        <module name="org.apache.commons.collections"/>

        <module name="org.dom4j"/>

        <module name="org.javassist"/>

        <module name="org.jboss.logging"/>

      </dependencies>

      </module>


      2: Set persistence.xml

       

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

       

       

      Result:

      Caused by: javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'org.batoo.jpa.core.BatooPersistenceProvider' not found

       

       

      Please Help !!!

        • 1. Re: How to use Batoo with AS7
          Stefan Schueffler Newbie

          Hi

           

          Step 1: prepare the module:

          Create directory

          {noformat} $JBOSS_HOME/modules/org/batoo/main {noformat}

           

          Drop those files there:

           

          {noformat}

          antlr-runtime-3.4.jar

          batoo-jpa-2.0.1-RTM.jar (or whatever version you are using)

          bonecp-0.7.1.RELEASE.jar

          commons-db-utils-1.4.jar

          {noformat}

           

          Edit module.xml:

           

          {code:xml}

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

          <module xmlns="urn:jboss:module:1.1" name="org.batoo">

              <resources>

                  <resource-root path="batoo-jpa-2.0.1.0-RTM.jar"/>

                  <resource-root path="commons-dbutils-1.4.jar"/>

                  <resource-root path="bonecp-0.7.1.RELEASE.jar"/>

                  <resource-root path="antlr-runtime-3.4.jar"/>

              </resources>

              <dependencies>

                  <module name="asm.asm"/>

                  <module name="com.google.guava"/>

                  <module name="javax.persistence.api"/>

                  <module name="javax.transaction.api"/>

                  <module name="javax.validation.api"/>

                  <module name="javax.xml.bind.api"/>

                  <module name="org.apache.commons.collections"/>

                  <module name="org.apache.commons.beanutils"/>

                  <module name="org.apache.commons.lang"/>

                  <module name="org.apache.commons.pool"/>

                  <module name="org.apache.commons.io"/>

                  <module name="org.slf4j"/>

                  <module name="org.jboss.as.jpa.spi" />

                  <module name="org.jboss.jandex" />

              </dependencies>

          </module>

          {code}

           

           

          In your ear-file, edit persistence.xml:

          {code:xml}

          <persistence ...>

             <persistence-unit ...>

                <!-- set the provider to batoo: -->

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

           

                 <properties>

                       <!-- JBOSS-specific: tell jboss, in which module it finds the batoo classes: -->

                       <property name="jboss.as.jpa.providerModule" value="org.batoo"/>

           

                      ... other batoo properties if any ...

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

           

                      ... other properties if any ...

           

                 </properties>

           

             </persistence-unit>

          </persistence>

          {code}

          • 2. Re: How to use Batoo with AS7
            Nicklas Karlsson Master

            There is of course the possibility that Batoo is so fast that the AS can't see it! ;-)

            • 3. Re: How to use Batoo with AS7
              floflo floflo Newbie

              hello i try this:

               

              I create: $JBOSS_HOME/modules/org/batoo/main

              i rename : batoo-jpa-2.0.1.0-20130125.014054-12.jar in batoo-jpa-01.jar

              I drop those files in:

              batoo-jpa-01.jar, commons-dbutils-1.4.jar, antlr-runtime-3.4.jar, asm-4.0.jar

               

              my module.xml in this repository:

              <module xmlns="urn:jboss:module:1.1" name="org.batoo">
                  <resources>
                      <resource-root path="batoo-jpa-01.jar"/>
                      <resource-root path="commons-dbutils-1.4.jar"/>
                      <resource-root path="antlr-runtime-3.4.jar"/>
                      <resource-root path="asm-4.0.jar"/>
                  </resources>
                  <dependencies>
                      <module name="com.google.guava"/>
                      <module name="javax.persistence.api"/>
                      <module name="javax.transaction.api"/>
                      <module name="javax.validation.api"/>
                      <module name="javax.xml.bind.api"/>
                      <module name="org.apache.commons.collections"/>
                      <module name="org.apache.commons.beanutils"/>
                      <module name="org.apache.commons.lang"/>
                      <module name="org.apache.commons.pool"/>
                      <module name="org.apache.commons.io"/>
                      <module name="org.slf4j"/>
                                  <module name="org.jboss.as.jpa.spi" />
                                  <module name="org.jboss.jandex" />
                  </dependencies>
              </module>
              
              

               

              my persistence.xml:

              <?xml version="1.0" encoding="UTF-8"?>
              <persistence version="1.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_1_0.xsd">
                  <persistence-unit name="McustomsEjbPU" transaction-type="JTA">
                      <jta-data-source>java:jboss/datasources/preProdDataSource</jta-data-source>
              
                      <provider>java:jboss/org.batoo.jpa.core.BatooPersistenceProvider</provider>
                      <properties>
                          <property name="jboss.as.jpa.providerModule" value="org.batoo" />
                      </properties>
                  </persistence-unit>
              </persistence>
              
              

               

               

              Caused by: javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'java:jboss/org.batoo.jpa.core.BatooPersistenceProvider' not found

               

              Please Help

              • 4. Re: How to use Batoo with AS7
                Stefan Schueffler Newbie

                The "value" attribute in your persistence.xml on the property named "jboss.as.jpa.providerModule" has to match the module name in your module.xml

                If your module is named "org.batoo", the same must be used in your persistence.xml (i.e. <property name="jboss.as.jpa.providerModule" value="org.batoo" />

                 

                Also, the provider in your persistence.xml should be:

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

                • 5. Re: How to use Batoo with AS7
                  floflo floflo Newbie

                  hello Stefan Schueffler, thanks for your help !!!

                  So new step, new error...

                  maybe i have a pb with dependecies version???

                   

                   

                  09:01:07,158 WARN  [org.batoo.common.reflect.ReflectHelper] (MSC service thread 1-3) Direct access library cannot be loaded! Direct access library only adds some performance, but not necessary to operate. It is safe to ignore...

                  09:01:07,966 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-2) Hibernate Validator 4.2.0.Final

                  09:01:08,051 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.persistenceunit."McustomsEAR.ear/McustomsEjb.jar#McustomsEjbPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."McustomsEAR.ear/McustomsEjb.jar#McustomsEjbPU": Failed to start service

                            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_30]

                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_30]

                            at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_30]

                  Caused by: java.lang.IncompatibleClassChangeError: Found class org.objectweb.asm.FieldVisitor, but interface was expected

                            at org.batoo.jpa.core.impl.instance.Enhancer.create(Enhancer.java:99)

                            at org.batoo.jpa.core.impl.instance.Enhancer.enhance0(Enhancer.java:456)

                            at org.batoo.jpa.core.impl.instance.Enhancer.enhance(Enhancer.java:452)

                            at org.batoo.jpa.core.impl.model.EntityTypeImpl.enhance(EntityTypeImpl.java:244)

                            at org.batoo.jpa.core.impl.model.EntityTypeImpl.<init>(EntityTypeImpl.java:206)

                            at org.batoo.jpa.core.impl.model.MetamodelImpl.<init>(MetamodelImpl.java:224)

                            at org.batoo.jpa.core.impl.manager.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:157)

                            at org.batoo.jpa.core.impl.manager.JtaEntityManagerFactoryImpl.<init>(JtaEntityManagerFactoryImpl.java:77)

                            at org.batoo.jpa.core.BatooPersistenceProvider.createContainerEntityManagerFactory(BatooPersistenceProvider.java:71)

                            at org.batoo.jpa.core.BatooPersistenceProvider.createContainerEntityManagerFactory(BatooPersistenceProvider.java:43)

                            at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                            at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                  • 6. Re: How to use Batoo with AS7
                    Stefan Schueffler Newbie

                    Hi

                     

                    maybe this is a dependency error, maybe this is a bug in batoo. Unfortunately i do not have enough of expertise to tell this just from your stacktrace.

                    Best thing would be to ask this question in batoo forum or github/batoo-issues.

                     

                    In my very own testing of batoo and jboss, batoo only works for most simple (test) cases. Many advanced features of JPA like derived entities with complex relationships, some EQL features etc are still not working yet resulting in various deployment erros.

                     

                    Nonetheless, batoo looks very promising as it validates everything much more strict than hibernate does: many "invalid" jpa annotation (silently ignored by hibernate, or converted using "best guess") are strictly failed by batoo, which all overall improves our code quality (e.g. having an @Enumerated annotation on a "String" field (resulting from some copy and paste) is just ignored by hibernate, whereas batoo does not deploy my application).

                     

                    Although batoo currently unfortunately also fails on many "allowed" jpa things, the batoo developer team is very pleasant and helpfull in fixing all the issues.

                     

                    As for the dependencies you asked for: i'm using the (dependency-) versions as given in my original post for batoo-2.0.1.0-RTM, and testing different batoo versions from self compiled github downloads (along with their corresponding dependencies, as they change over time like bonecp).

                     

                    Stefan

                    • 7. Re: How to use Batoo with AS7
                      floflo floflo Newbie

                      it was my asm 4 library

                      it s ok i take asm : http://mvnrepository.com/artifact/asm/asm-all/3.3.1

                      thank you for all !!!!!!