2 Replies Latest reply on Dec 21, 2012 7:35 AM by Aristides Neto

    Configure JavaAgent in JBoss to enhance OpenJPA entities

    Aristides Neto Newbie

      Hello everyone,

       

      I´m trying to configure JBoss AS 7 to use OpenJPA as provider, I gatthered a lot of info from the forum and I think I got everything configured and working.

       

      My problem now is that I can´t make the OpenJPA JavaAgent to enhance the entities. I know that there´s build options to enhance the entities, but it doesn´t like when an Entity in module A extends an entity in module B, also I have several modules and I´m not done with adding maven and would be difficult to enhance all of then.

       

      I´ve tried to edit the standalone.conf :

       

      JAVA_OPTS="$JAVA_OPTS -javaagent:C:\\dev\\jboss-as-7.1.1.Final\\modules\\org\\apache\\openjpa\\main\\openjpa-all-2.2.0.jars"

       

      I ´ve also tried setting the JBOSS_MODULES_SYSTEM_PKGS="org.apache.openjpa".

      But in any case I don´t get the entities enhance and the OpenJPA throws an error saying that the enhance was not done.

       

      I´m open to suggestions and I would like to thanks everybody for the help.

       

       

      Thanks,

      Aristides

        • 1. Re: Configure JavaAgent in JBoss to enhance OpenJPA entities
          Nicklas Karlsson Master

          Are there indications the agent is picked up? / (forward-slash) is probably better than \\ (double-backslash)

          1 of 1 people found this helpful
          • 2. Re: Configure JavaAgent in JBoss to enhance OpenJPA entities
            Aristides Neto Newbie

            Thanks Nicklas, yes changing the "\\" to "/" did seen to make the agent start working,

             

            JAVA_OPTS="$JAVA_OPTS -javaagent:C:/dev/jboss-as-7.1.1.Final/modules/org/apache/openjpa/main/openjpa-all-2.2.0.jars"

             

            Now I´m having problem with the classpath, this agent depends on an couple of jars, like: commons-lang-2.1.jar, geronimo-jpa_3.0_spec-1.0.jar and geronimo-jta_1.1_spec-1.1.jar.

            This jars are parte of my module (modules\org\apache\openjpa\main), but I understand that they run in a separate classloader.

             

            If I just run I get a CNFE on a commons-lang class, so I added this libraries using:

             

            JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/a:C:/dev/jboss-as-7.2.0.alpha2/modules/org/apache/openjpa/main/commons-lang-2.1.jar"

             

            So if I do this for all dependencies the CNFE doesn´t appear, but latter on initialization I get a ClassCastException when JBoss is processing the persistence.xml and tries to load the class org.apache.openjpa.persistence.PersistenceProviderImpl.

             

            I think the ClassCastException is caused because the PersistenceProviderImpl appears both in the agent and in the openjpa module.

             

            So my question, Is there a way to make the agent work without affecting the application classloader?