[wildfly-dev] How to put AspectJ aspects on the classpath to advise core classes in Wildfly?
Eric B
ebenzacar at gmail.com
Mon Oct 23 11:04:12 EDT 2017
Thanks for the tips, but i'm still struggling with this. Here's what I've
done so far.
I've added the module name under -Djboss.modules.system.pkgs and added it
as a cp argument as :
-Djboss.modules.system.pkgs=org.jboss.byteman,org.aspectj,org.jboss.logmanager
-classpath
"D:\jboss-eap-7.0\modules\system\layers\base\org\aspectj\main\aspectj-0.0.1-SNAPSHOT.jar"
My org.aspectj module is defined as:
<module xmlns="urn:jboss:module:1.3" name="org.aspectj">
<resources>
<resource-root path="aspectjweaver-1.8.10.jar"/>
<resource-root path="aspectj-0.0.1-SNAPSHOT.jar"/>
</resources>
</module>
Now when I start Wildfly, I still don't see it trying to weave any of the
base Wildfly/undertow modules. If I define the org.aspectj as a global
module in the standalone.xml, the I see the weaver attempting to weave my
application deployment but none of the base WF classes.
Does the jboss.modules.system.pkgs argument relate to the module name or to
the package naming of the libraries? ie: do my aspects in
aspectj-0.0.1-SNAPSHOT.jar also have to be in an 'org.aspectj' java
package or am I free to use any package naming structure I want as long as
they are part of the org.aspectj WF module definition? My aspect is
actually in a test package called "aspectj". I even tried added "aspectj"
to the jboss.modules.system.pkgs variable, but to no avail.
How does WF know where to find classes/packages defined in
'jboss.modules.system.pkgs'?
Thanks,
Eric
On Sun, Oct 22, 2017 at 7:09 PM, Stuart Douglas <stuart.w.douglas at gmail.com>
wrote:
> I think you probably want to modify the classpath and also
> add -Djboss.modules.system.pkgs=org.aspectj (or whatever package aspectj
> classes are under). This system property is a comma separated list of
> non-modular packages that JBoss modules will just pass straight through to
> the system class loader.
>
> Stuart
>
> On Sat, Oct 21, 2017 at 1:29 AM, Eric B <ebenzacar at gmail.com> wrote:
>
>> I'm trying to use AspectJ to advise some core classes in
>> Wildfly/undertow. Specifically, I'm trying to advise some of the Undertow
>> HttpSession methods to get some more detailed logging when Sessions are
>> created/expire/etc.
>>
>> I've added AspectJ as a -javaagent which is launched on startup of
>> Wildfly. I had to follow some of the steps listed at:
>> https://github.com/ChienChingLee/How-to-launch-Wildfly-
>> 9.0-with-AspectJ-1.8-LTW. But it works; I can see that the AJ weaver is
>> loaded and present.
>>
>> My problem now is that I don't know where to put my jar of aspects for it
>> to be loaded/visible by the weaver for all modules. I've managed to get it
>> to work by modifying the io.undertow.servlet module, adding my jar in the
>> folder and modifying the module.xml, but that only advises the
>> io.undertow.servlet.* classes. And it seems like quite an ugly hack to get
>> to that.
>>
>> I tried creating an independent module for it, and declaring it as a
>> global module in my standalone.xml, but that didn't seem to work. Nor did
>> modifying the servlet module.xml and specifying my module as a dependency.
>>
>> I tried to add it to the startup parameters in the standalone.conf file,
>> specifying it as -classpath path/to/myaspect.jar, but that only advised the
>> startup WF (org.jboss) classes and none of the modules.
>>
>> At the moment, I'm looking to advise any implementation of
>> javax.servlet.http.HttpSession.invalidate(). In AJ language, the
>> pointcut is simple: execution(* javax.servlet.http.HttpSession+.invalidate(..))
>> will match any implementation of the HttpSession interface. However, to
>> make it active, I need to get that Aspect in the classpath of every module
>> loaded and visible to the AJ weaver.
>>
>> Is there a "generic" place I can declare the the aspects.jar so that it
>> is part of the classpath of every module loaded or is my only choice to
>> modify every module.xml in the system?
>>
>> Thanks,
>>
>> Eric
>>
>>
>> _______________________________________________
>> wildfly-dev mailing list
>> wildfly-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/wildfly-dev/attachments/20171023/92975577/attachment.html
More information about the wildfly-dev
mailing list