4 Replies Latest reply on Nov 22, 2013 7:04 AM by aiellomau

    OpenJPA : JBossPersistenceMetaDataFactory ClassNotFoundException

      I'm not able to deploy a war on JBoss AS 7.1.1.

      Every time I got

      at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:131)

          at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:65)

          ... 10 more

      Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.jboss.as.jpa.openjpa.JBossPersistenceMetaDataFactory from [Module "org.jboss.as.jpa:main" from local module loader @9175 (roots: /opt/jboss/modules)]

          at serp.util.Strings.toClass(Strings.java:164)

          at serp.util.Strings.toClass(Strings.java:108)

          at org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:214)

       

       

      persistence.xml:

       

      <persistence-unit name="gwn10000Slice">

              <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

              <jta-data-source>java:jboss/datasources/GetWellAtHome</jta-data-source>

       

              <class>.... listed classes</class>

       

              <properties>

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

                  <property name="jboss.as.jpa.adapterModule" value="org.jboss.as.jpa.openjpa" />

                  <property name="jboss.as.jpa.adapterClass"

                      value="org.jboss.as.jpa.openjpa.OpenJPAPersistenceProviderAdaptor" />

       

                  <property name="openjpa.TransactionMode" value="managed" />

                  <property name="openjpa.ConnectionFactoryMode" value="managed" />

       

                  <property name="openjpa.DynamicEnhancementAgent" value="false" />

                  <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />

                  <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />

                  <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />

       

                  <property name="openjpa.BrokerFactory" value="slice" />

                  <property name="openjpa.slice.Names" value="GetWellAtHome,GetWellAtHome_GWN" />

                  <property name="openjpa.slice.Master" value="GetWellAtHome" />

                  <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />

                  <property name="openjpa.slice.Lenient" value="true" />

              </properties>

          </persistence-unit>

       

       

      jboss-deployment-structure.xml

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

      <jboss-deployment-structure>

          <deployment>

              <dependencies>

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

                   <module name="org.apache.openjpa" />

              </dependencies>

              <!-- Exclusions allow you to prevent the server from automatically adding

                  some dependencies -->

              <exclusions>

                  <module name="org.apache.log4j" />

                  <module name="org.apache.slf4j" />

                  <module name="org.apache.httpcomponents" />

              </exclusions>

          </deployment>

      </jboss-deployment-structure>

       

      and also I have openjpa apache jar on $JBOSS_HOME/modules/org/apache/openjpa/main

      module.xml:

       

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

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

          <resources>

              <resource-root path="openjpa-2.2.2.jar"/> <!-- also I openjpa-all-2.2.2.jar tried -->

              <resource-root path="serp-1.14.1.jar"/>

          </resources>

       

          <dependencies>

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

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

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

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

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

              <module name="org.apache.log4j"/>

          </dependencies>

      </module>

       

      What could be the problem?

      It seems that the classloader  try to get the class org.jboss.as.jpa.openjpa.JBossPersistenceMetaDataFactory from module org.jboss.as.jpa:main and not from org.jboss.as.jpa.openjpa:main

       

      How can I fix this?

        • 1. Re: OpenJPA : JBossPersistenceMetaDataFactory ClassNotFoundException
          smarlow

          You shouldn't need to include the OpenJPA dependencies in jboss-deployment-structure. 

           

          Have you tried with WildFly 8 yet?  The WildFly 8 testsuite does some basic testing with OpenJPA (as well as EclipseLink and a lot of testing with Hibernate).  Currently, we are testing with OpenJPA 2.2.2.  The module.xml definition file that we use in WildFly is here.  You seem to have fewer dependencies in yours.

           

          With WildFly 8, you only have to copy the OpenJPA jar into the WildFly/modules/system/layers/base/org/apache/openjpa/main folder and update the module.xml to include the OpenJPA jar name.  You no longer need the jboss.as.jpa.providerModule, jboss.as.jpa.adapterModule and jboss.as.jpa.adapterClass properties in the persistence.xml since the classes are already included in the above folder path (so they don't have to be specified by name).

           

          Please let us know if you have difficulties with using OpenJPA + WildFly 8.

           

          Scott

          1 of 1 people found this helpful
          • 2. Re: OpenJPA : JBossPersistenceMetaDataFactory ClassNotFoundException

            Scott,

            thank for your quick response!..

            I never try WildFly. Unfortunately WildFly is an application server and my wish is to run OpenJPA within a JBoss AS 7.1.1 environment.

            Can WildFly help me with that?

            • 3. Re: OpenJPA : JBossPersistenceMetaDataFactory ClassNotFoundException

              oh, I've just realised that "WildFly 8" is the new name JBoss AS. That means that we need to upgrade to use WildFly and that is not a good idea, we actually have some servers running with JBoss AS 7.1.1. So I will insist try to running on that env.

               

              Any suggestions?

              • 4. Re: OpenJPA : JBossPersistenceMetaDataFactory ClassNotFoundException

                I resolved by adding the following line on my persistence.xml

                 

                <property name="openjpa.MetaDataFactory" value="jpa(ClasspathScan=build;lib.jar)"/>

                 

                With that line the error has disappeared?

                 

                Now I have another issue with the openjpa slices connections. If I have no success I will created a topic for this new issue:

                 

                Caused by: java.sql.SQLException: A connection could not be obtained for driver class "com.mysql.jdbc.Driver" and URL "null".  You may have specified an invalid URL.