6 Replies Latest reply on Jul 12, 2012 10:29 AM by Francesco Chicchiriccò

    OpenJPA-2.2.0 on JBossAS-7.1.0.Final

    Mark Struberg Newbie

      Since Martin nagged me I gonna share my small configuration to get OpenJPA-2.2.x running on JBossAS-7

       

       

      1. create a directory modules/org/apache/openjpa/main

       

      $> cd ${jbossas.home}
      $> mkdir -p modules/org/apache/openjpa/main
      

       

       

      It will finally contain the following content:

       

      /opt/jboss-as-7.1.0.Final$>tree modules/org/apache/openjpa/
      modules/org/apache/openjpa/
      └── main
          ├── module.xml
          ├── openjpa-jdbc-2.2.0.jar
          ├── openjpa-jdbc-2.2.0.jar.index
          ├── openjpa-kernel-2.2.0.jar
          ├── openjpa-kernel-2.2.0.jar.index
          ├── openjpa-lib-2.2.0.jar
          ├── openjpa-lib-2.2.0.jar.index
          ├── openjpa-persistence-2.2.0.jar
          ├── openjpa-persistence-2.2.0.jar.index
          ├── openjpa-persistence-jdbc-2.2.0.jar
          └── openjpa-persistence-jdbc-2.2.0.jar.index
      

       

      2. create the file module.xml

       

      vi ./modules/org/apache/openjpa/main/modules.xml
      

      with the following content:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="org.apache.openjpa">
          <resources>
              <resource-root path="openjpa-kernel-2.2.0.jar"/>
              <resource-root path="openjpa-lib-2.2.0.jar"/>
              <resource-root path="openjpa-persistence-2.2.0.jar"/>
              <resource-root path="openjpa-jdbc-2.2.0.jar"/>
              <resource-root path="openjpa-persistence-jdbc-2.2.0.jar"/>
          </resources>
       
          <dependencies>
              <module name="javax.persistence.api"/>
              <module name="javax.transaction.api"/>
              <module name="javax.validation.api"/>
              <module name="org.apache.commons.lang"/>
              <module name="org.apache.commons.collections"/>
              <module name="org.apache.log4j"/>       
              <module name="asm.asm"/>       
          </dependencies>
      </module>
      

       

       

      3.) download the Apache OpenJPA distribution bundle from http://openjpa.apache.org/ and extract the files listed above to ./modules/org/apache/openjpa/main/

       

      have fun!

       

      LieGrue,

      strub

        • 1. Re: OpenJPA-2.2.0 on JBossAS-7.1.0.Final
          Mark Struberg Newbie

          PS: the log4j dependency is optional. The logger which gets used can be configured in your persistence.xml via the openjpa.Log property:

          http://openjpa.apache.org/builds/latest/docs/docbook/manual/ref_guide_conf_openjpa.html#openjpa.Log

          • 2. Re: OpenJPA-2.2.0 on JBossAS-7.1.0.Final
            Stephen Coy Master

            This seems like a good topic for an article.

             

            (hint, hint)

            • 3. Re: OpenJPA-2.2.0 on JBossAS-7.1.0.Final
              Francesco Chicchiriccò Newbie

              Interesting option!

               

              However, I've found these issues so far:

              1. 'modules.xml' should instead be 'module.xml' [SOLVED]
              2. I had to add serp-1.13.1.jar to the directory and to the module.xml file [SOLVED]
              3. whatever JPA query my application performs, I get

               

              org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT e FROM  ExternalResource e". Error message: The name "ExternalResource" is not a recognized entity or identifier. Perhaps you meant ExternalResource, which is a close match. Known entity names: [ExternalResource, AbstractSchema, RAttrUniqueValue, AbstractVirAttr, Membership, TaskExec, SyncopeConf, Report, RAttr, AbstractExec, SyncopeLogger, USchema, MAttr, PasswordPolicy, RSchema, MSchema, MAttrValue, MAttrUniqueValue, AbstractAttr, AbstractDerSchema, AbstractVirSchema, UAttr, AccountPolicy, RAttrValue, UAttrValue, ReportExec, SyncopeUser, Notification, ConnInstance, AbstractDerAttr, AbstractAttrValue, SyncopeRole, SyncPolicy, Policy, ReportletConfInstance, Task, UAttrUniqueValue, Entitlement, SchemaMapping, UserRequest]
              

               

              I've taken a look at JPQLExpressionBuilder.getClassMetaData() and it seems to me that the problem might lie in some hidden Classloader thing: any hint?

              • 4. Re: OpenJPA-2.2.0 on JBossAS-7.1.0.Final
                Mark Struberg Newbie

                Hi Francesco!

                I've only tested it with resource-local (Persistence.createEntityManagerFactory().createEntityManager()...) but that worked fine!

                Please note that OpenJPA needs all entities as <class> entries in the persistence.xml file.

                • 5. Re: OpenJPA-2.2.0 on JBossAS-7.1.0.Final
                  Francesco Chicchiriccò Newbie

                  Hi Mark,

                  I am actually trying to deploy Apache Syncope on JBoss AS 7.1 without Hibernate support: this means that I am actually using a Spring-injected EntityManager and persistence.xml.

                   

                  Additionally, the entity classes are actually recognized by OpenJPA: the exception stacktrace above says:

                   

                  Known entity names: [AbstractSchema, ExternalResource, RAttrUniqueValue, Membership, TaskExec, SyncopeConf, Report, RAttr, AbstractExec, SyncopeLogger, USchema, PasswordPolicy, MAttr, RSchema, MSchema, MAttrValue, MAttrUniqueValue, AbstractAttr, AbstractDerSchema, UAttr, AccountPolicy, RAttrValue, ReportExec, UAttrValue, SyncopeUser, ConnInstance, AbstractDerAttr, AbstractAttrValue, SyncopeRole, SyncPolicy, Policy, ReportletConfInstance, Task, UAttrUniqueValue, Entitlement, SchemaMapping]

                   

                  I feel a bit surprised by

                   

                  Error message: The name "ExternalResource" is not a recognized entity or identifier. Perhaps you meant ExternalResource, which is a close match.

                  • 6. Re: OpenJPA-2.2.0 on JBossAS-7.1.0.Final
                    Francesco Chicchiriccò Newbie

                    I've managed to fix this issue (and provided a patch to the OpenJPA project) - hope the guys there will apply it soon!

                     

                    However, I was able to do everything without the need of defining an OpenJPA module: just bundled JARs in my webapp and everything worked fine.