Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Enabling LTW dynamically without the -javaagent?

I am not versed in container applications, but your understanding here

any classes loaded prior to the LTW agent being attached won't be woven

is correct. In a way, this thought is also somewhat pacifying because it should not be so easy to mess with classloading inside a container as this could be considered a security problem. So unless you have control over how the container is started (-javaagent) or find a way to hook into classloading, you should rather resort to CTW. But maybe someone else here knows how to do what you want from within a container. There might be container-specific ways or even standardised ones, but I do not have the slightest idea. So why not use CTW in connection with 'if()' pointcuts and a configurable condition in order to toggle aspect execution?

--
Alexander Kriegisch
https://scrum-master.de
 
 
Eric B schrieb am 18.10.2017 03:30:
Thanks for the link/pointer.  I read through it, but am still unclear how/where this becomes useful.  It is obvious how it can be used in a standard console java application with a single "main" entry point.  This would also apply to any self-contained Spring Boot applications (or their equivalences).  But can something like this be used in any web container?  Be it a tomcat, jetty, wildfly, etc. ?  I don't know of a single entry point, equivalent to a "main" in a console application.  
 
From what I understand from the release notes, any classes loaded prior to the LTW agent being attached won't be woven.  So in the case of a JEE app (ie: EJBs, etc), the container scans and loads beans in the Dependency tree long before the application "starts".  So one would need to hook into the classloading mechanism itself, or provide a custom classloader?  Do you know if there is a mechanism to do this reliably?  I would obviously want the Agent loaded as the first class in my EAR.
 
 
On Tue, Oct 17, 2017 at 6:00 PM, Alexander Kriegisch <alexander@xxxxxxxxxxxxxx> wrote:
I remember that one, Andy Clement accepted my corresponding patch a while ago.
 

Am 17.10.2017 um 17:56 schrieb Eric B <ebenzacar@xxxxxxxxx>:
 
Just a quick followup - this is JEE application - NOT a Spring application, if that makes any difference to enabling LTW dynamically.
 
 
On Tue, Oct 17, 2017 at 11:54 AM, Eric B <ebenzacar@xxxxxxxxx> wrote:
I recently read something on a Redhat tech doc (https://access.redhat.com/solutions/328513) indicating that as of AspectJ 1.8.7, one can enable LTW without using the javaagent on JVM startup.  I've done a quick google search to see if I can find additional documentation/references to this, but can't seem to find relevant links for it.
 
Note: The AspectJ 1.8.7 loadtime weaving agent can now be dynamically attached to a JVM after it has started no need to use -javaagent just add the AspectJ libs to the war lib folder.
Can anyone provide me with more information as to what is required to enable LTW in an EAR project?  Do I just have to drop the aspectjweaver.jar in the EAR/lib folder?  What mechanism is being used to inject the weaving agent?  Is there additional documentation in the AJ docs that pertains to this that I missed?  I don't see anything on: https://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html#enabling-load-time-weaving

Back to the top