[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW Agent Dynamic Attachement with Attach API

Hi Jean-Louis,

I'd suspect we need the weaver to perhaps implement a new interface or two, so that it can be plugged in via that route - but I haven't looked into it.  I don't think we have an open enhancement request to support this, so you could create one.  And if you discover the magic we need to get it working, please add it to the enhancement - that would be the easiest way to get it done in the 1.6.4 timeframe.  I don't think it will be too complex as the weaver doesn't have any logic in to stop you trying to do this.

The disadvantage of attaching any time later than right up front is simply that things will not have been woven that have already been loaded (unless they are reloaded after the weaver is attached). 


2009/1/6 <jeanlouis.pasturel@xxxxxxxxxxxxxxxxxx>

I have yet asked the question, and I made a try.

JDK 1.6 brings Sun Api to dynamically load java Agent http://java.sun.com/javase/6/docs/technotes/guides/attach/index.html


I test it with aspectjweaver.jar ( in fact a custom myaspectjweaver.jar that contains aspectjweaver.jar ) but I can't success a run.


Does-it possible to attach LTW agent, when an application is already running?

 Or the LTW agent *must* be loaded at starting?


 I see that there is some thing similar with the Equinox/Aspects; project in status incubator…


I load the Agent but the initialisation failed as shown with this traces:


E:\opt\perfStats\scripts>"C:\Program Files\Java\jdk1.6.0_11\bin\java"   -classpath ..\lib\myaspectjweaver.jar;"C:\Program Files\Java\jdk1.6.0_11\lib\tools.jar";

;. attachapi.launcher.PerfStatsLaunch 4668 E:\opt\perfStats\lib\myaspectjweaver.jar

loading agent : E:\opt\perfStats\lib\myaspectjweaver.jar

Echec Attach

com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

        at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:103)

        at attachapi.launcher.PerfStatsLaunch.attachPerfStats(PerfStatsLaunch.java:33)

        at attachapi.launcher.PerfStatsLaunch.main(PerfStatsLaunch.java:69)



Manifest-Version: 1.0

Name: org/aspectj/weaver/

Specification-Title: AspectJ Weaver Classes

Specification-Version: DEVELOPMENT

Specification-Vendor: aspectj.org

Implementation-Title: org.aspectj.weaver

Implementation-Version: DEVELOPMENT

Implementation-Vendor: aspectj.org

Premain-Class: org.aspectj.weaver.loadtime.Agent

Can-Redefine-Classes: true

Agent-Class: org.aspectj.weaver.loadtime.Agent


I added the Agent-Class line.




Cordialement / Best regards

Jean-Louis Pasturel


This message and any attachments (the "message") are confidential and intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration.
France Telecom Group shall not be liable for the message if altered, changed or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender.

aspectj-users mailing list