0 Replies Latest reply on May 24, 2016 7:22 AM by Pedro Pereira

    Wildfly and AspectJ: How to add dependencies to AOP module

    Pedro Pereira Newbie

      Hi everyone.

       

      I'm trying to use AspectJ with JBoss in order to audit some methods from a webapp that is not mine.

      I've configured JBoss to load AspectJ successfully, and created a module for my auditing with my aspects.

       

      This is my module configuration:

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.3" name="my.aop.module">
          <resources>
              <resource-root path="otmm-aop-16.0-SNAPSHOT.jar"/>
          </resources>
        <dependencies>
        <module name="org.aspectj.runtime"  export="true"/>
        <module name="org.aspectj.weaver"  export="true"/>
        <module name="org.jboss.log4j.logmanager"  export="true"/>
        </dependencies>
      </module>
      

       

      I've added that module as a global module to standalone.xml:

              <subsystem xmlns="urn:jboss:domain:ee:3.0">
                  <global-modules>
                      <module name="my.aop.module"/>
                  </global-modules>
      

       

      I am able to successfully catch my pointcuts inside the webapp, so everything seems to be fine with the AOP.

      My issue is that then, inside my module, I need to use classes that are defined in the webapp, but I get a NoClassDefFound error.

      Caused by: java.lang.ClassNotFoundException: third.party.jar.Class from [Module "my.aop.module:main" from local module loader @3b0143d3 (finder: local module finder @5a8e6209 (roots: C:\wildfly\modules,C:\wildfly\modules\system\layers\base,C:\CustomDeploymentsFolder,C:\CustomDeploymentsFolder))]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)
        ... 57 more
      

       

      I assume this is because those classes are loaded in the webapp context, while my module is loaded in the server context, so my module does not have access to those classes.

      Is there a way to set jar dependencies to my module ? I've tried to add system dependencies to my module but with no success:

      <system export="true">
        <paths>
          <path name="C:\CustomDeploymentsFolder\thirdparty-webapp.ear\restapi.war\WEB-INF\lib"/>
        </paths>
      </system>
      

       

      I've also tried to load the module in the webapp context, as s submodule on the EAR's application.xml, but in that case I can't catch the pointcuts, it seems that AOP does not work that way.

       

      Any clues on how can I achieve this ?

       

      Thanks.

      Best regards.