Discussion:
[aspectwerkz-user] remote weaving?
Dongkwan Kim
2007-10-03 19:01:06 UTC
Permalink
Does AspectWerkz support the remote weaving? Let me explain my scenario in
detail.
Suppose there is a running Java application. It don't know AspectWerkz. I
want to insert an aspect into the running application. This is called the
remote weaving. Is there any way to weave already running Java classes?

DK
Jonas Bonér
2007-10-08 08:52:03 UTC
Permalink
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny hooks,
but no aspects). Then you can do hot deploy and undeploy in a running
system.
Details here: http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects

/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my scenario in
detail.
Suppose there is a running Java application. It don't know AspectWerkz. I
want to insert an aspect into the running application. This is called the
remote weaving. Is there any way to weave already running Java classes?
DK
--
Jonas Bonér

http://jonas
neo anderson
2008-10-19 20:50:47 UTC
Permalink
I follow the example at
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html
to do hot deployment, but it fails. There is no error returned to the
screen. It only prints message like:

Deployer::INFO - deploying aspect [aspect.Observer] in class loader
sun.misc.Launcher$***@1a16869]

The target application does not print out anything.

The code to do deployment is

package action;

public class Detector{

...
void detect(){
System.out.println("Enable aspect! ...");
Deployer.deploy(Observer.class, toXML());
}
...
private String toXML(){
return "<aspect class=\"Observer\"><pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/></aspect>";
/* //this xml throws not well formed xml definition exception
return "<aspectwerkz>\n" +
"<system id=\"Mock Server\">\n"+
" <package name=\"aspect\">\n"+
" <aspect class=\"Observer\">\n"+
" <pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/>\n"+
" <advice name=\"beforeCount\"
type=\"before\" bind-to=\"count\"/>\n"+
" <advice name=\"afterCount\"
type=\"after\" bind-to=\"count\"/>\n"+
" </aspect>\n"+
" </package>\n"+
" </system>\n"+
"</aspectwerkz>\n";
*/
}

Where the Observer.java aspect and the application (Server.java) to be
weaved is the same as
http://www.nabble.com/Runtime-weaving-question-to20042123.html

The way to test runtime weaving scenario is
1.) launch the server
2.) deploy the aspect by `java -cp
"target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`

I also have a look at the example in jdk15/test folder, in which it seems
like the hot deployment is done on the same jvm, e.g.

public class HotDeployedTest ...
public void testDeployment() {
...
Deployer.deploy(HotdeployableAspect.class);
target();
...

I think I have done something wrong, but do not know where it is. Would
anyone please give me some hint or advice?

Thank you very much,
Post by Jonas Bonér
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny hooks,
but no aspects). Then you can do hot deploy and undeploy in a running
system.
http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects
/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my scenario in
detail.
Suppose there is a running Java application. It don't know AspectWerkz. I
want to insert an aspect into the running application. This is called the
remote weaving. Is there any way to weave already running Java classes?
DK
--
Jonas Bonér
http://jonasboner.com
--
View this message in context: http://www.nabble.com/remote-weaving--tp13025650p20060099.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Alexandre Vasseur
2008-10-21 09:10:38 UTC
Permalink
hot deployment MUST be in the same VM yes. Think deployment (of new aspect
but whose compiled code is already available) as a "runtime weaving"
Amex
Post by neo anderson
I follow the example at
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html
to do hot deployment, but it fails. There is no error returned to the
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
The target application does not print out anything.
The code to do deployment is
package action;
public class Detector{
...
void detect(){
System.out.println("Enable aspect! ...");
Deployer.deploy(Observer.class, toXML());
}
...
private String toXML(){
return "<aspect class=\"Observer\"><pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/></aspect>";
/* //this xml throws not well formed xml definition exception
return "<aspectwerkz>\n" +
"<system id=\"Mock Server\">\n"+
" <package name=\"aspect\">\n"+
" <aspect class=\"Observer\">\n"+
" <pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/>\n"+
" <advice name=\"beforeCount\"
type=\"before\" bind-to=\"count\"/>\n"+
" <advice name=\"afterCount\"
type=\"after\" bind-to=\"count\"/>\n"+
" </aspect>\n"+
" </package>\n"+
" </system>\n"+
"</aspectwerkz>\n";
*/
}
Where the Observer.java aspect and the application (Server.java) to be
weaved is the same as
http://www.nabble.com/Runtime-weaving-question-to20042123.html
The way to test runtime weaving scenario is
1.) launch the server
2.) deploy the aspect by `java -cp
"target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`
I also have a look at the example in jdk15/test folder, in which it seems
like the hot deployment is done on the same jvm, e.g.
public class HotDeployedTest ...
public void testDeployment() {
...
Deployer.deploy(HotdeployableAspect.class);
target();
...
I think I have done something wrong, but do not know where it is. Would
anyone please give me some hint or advice?
Thank you very much,
Post by Jonas Bonér
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny hooks,
but no aspects). Then you can do hot deploy and undeploy in a running
system.
http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects
Post by Jonas Bonér
/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my scenario in
detail.
Suppose there is a running Java application. It don't know AspectWerkz.
I
Post by Jonas Bonér
Post by Dongkwan Kim
want to insert an aspect into the running application. This is called
the
Post by Jonas Bonér
Post by Dongkwan Kim
remote weaving. Is there any way to weave already running Java classes?
DK
--
Jonas Bonér
http://jonasboner.com
--
http://www.nabble.com/remote-weaving--tp13025650p20060099.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
neo anderson
2008-10-26 13:24:25 UTC
Permalink
After trying several times, I still can not get the online weaving worked. I
think there are several things I still do not understand very well.

Mainly it is 'What is the correct way (scenario) to execute the online
weaving?'
From the document at http://aspectwerkz.codehaus.org/downloads/ saying that,
e.g. in transparent bootclasspath mode, running bin/aspectwerkz the first
JVM will launch the application JVM. However, if I switch to run
`$ASPECTWERKZ_HOME/bin/aspectwerkz -cp
"./:target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`

The output will shows some extra information

java ... -Xrunjdwp:transport=dt_socket,suspend=y,address=9300,server=y
-Xdebug -Xbootclasspath/p ...
...
Listening for transport dt_socket at address: 9300
Listening for transport dt_socket at address: 9300
AspectWerkz - INFO - Pre-processor
org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and
initialized
Enable aspect! ...
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
sun.misc.Launcher$***@17182c1]

but still there is no aop information weaved to the running server.

Would you please to give me some advice or hints? (Sorry for this newbie
question)

Thanks again for the help. I appreciate it.
hot deployment MUST be in the same VM yes. Think deployment (of new aspect
but whose compiled code is already available) as a "runtime weaving"
Amex
On Sun, Oct 19, 2008 at 10:50 PM, neo anderson
Post by neo anderson
I follow the example at
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html
to do hot deployment, but it fails. There is no error returned to the
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
The target application does not print out anything.
The code to do deployment is
package action;
public class Detector{
...
void detect(){
System.out.println("Enable aspect! ...");
Deployer.deploy(Observer.class, toXML());
}
...
private String toXML(){
return "<aspect class=\"Observer\"><pointcut
name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/></aspect>";
/* //this xml throws not well formed xml definition exception
return "<aspectwerkz>\n" +
"<system id=\"Mock Server\">\n"+
" <package name=\"aspect\">\n"+
" <aspect class=\"Observer\">\n"+
" <pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/>\n"+
" <advice
name=\"beforeCount\"
type=\"before\" bind-to=\"count\"/>\n"+
" <advice
name=\"afterCount\"
type=\"after\" bind-to=\"count\"/>\n"+
" </aspect>\n"+
" </package>\n"+
" </system>\n"+
"</aspectwerkz>\n";
*/
}
Where the Observer.java aspect and the application (Server.java) to be
weaved is the same as
http://www.nabble.com/Runtime-weaving-question-to20042123.html
The way to test runtime weaving scenario is
1.) launch the server
2.) deploy the aspect by `java -cp
"target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`
I also have a look at the example in jdk15/test folder, in which it seems
like the hot deployment is done on the same jvm, e.g.
public class HotDeployedTest ...
public void testDeployment() {
...
Deployer.deploy(HotdeployableAspect.class);
target();
...
I think I have done something wrong, but do not know where it is. Would
anyone please give me some hint or advice?
Thank you very much,
Post by Jonas Bonér
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny hooks,
but no aspects). Then you can do hot deploy and undeploy in a running
system.
http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects
Post by Jonas Bonér
/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my
scenario
Post by Jonas Bonér
Post by Dongkwan Kim
in
detail.
Suppose there is a running Java application. It don't know
AspectWerkz.
I
Post by Jonas Bonér
Post by Dongkwan Kim
want to insert an aspect into the running application. This is called
the
Post by Jonas Bonér
Post by Dongkwan Kim
remote weaving. Is there any way to weave already running Java
classes?
Post by Jonas Bonér
Post by Dongkwan Kim
DK
--
Jonas Bonér
http://jonasboner.com
--
http://www.nabble.com/remote-weaving--tp13025650p20060099.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
View this message in context: http://www.nabble.com/remote-weaving--tp13025650p20173427.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Alexandre Vasseur
2008-10-26 19:08:48 UTC
Permalink
please consider using the javaagent option. That is the best option to
consider in Java 5 / java 6.

On Sun, Oct 26, 2008 at 2:24 PM, neo anderson
Post by neo anderson
After trying several times, I still can not get the online weaving worked. I
think there are several things I still do not understand very well.
Mainly it is 'What is the correct way (scenario) to execute the online
weaving?'
From the document at http://aspectwerkz.codehaus.org/downloads/ saying that,
e.g. in transparent bootclasspath mode, running bin/aspectwerkz the first
JVM will launch the application JVM. However, if I switch to run
`$ASPECTWERKZ_HOME/bin/aspectwerkz -cp
"./:target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`
The output will shows some extra information
java ... -Xrunjdwp:transport=dt_socket,suspend=y,address=9300,server=y
-Xdebug -Xbootclasspath/p ...
...
Listening for transport dt_socket at address: 9300
Listening for transport dt_socket at address: 9300
AspectWerkz - INFO - Pre-processor
org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and
initialized
Enable aspect! ...
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
but still there is no aop information weaved to the running server.
Would you please to give me some advice or hints? (Sorry for this newbie
question)
Thanks again for the help. I appreciate it.
Post by Alexandre Vasseur
hot deployment MUST be in the same VM yes. Think deployment (of new
aspect
Post by Alexandre Vasseur
but whose compiled code is already available) as a "runtime weaving"
Amex
On Sun, Oct 19, 2008 at 10:50 PM, neo anderson
Post by neo anderson
I follow the example at
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html
Post by Alexandre Vasseur
Post by neo anderson
to do hot deployment, but it fails. There is no error returned to the
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
The target application does not print out anything.
The code to do deployment is
package action;
public class Detector{
...
void detect(){
System.out.println("Enable aspect! ...");
Deployer.deploy(Observer.class, toXML());
}
...
private String toXML(){
return "<aspect class=\"Observer\"><pointcut
name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/></aspect>";
/* //this xml throws not well formed xml definition exception
return "<aspectwerkz>\n" +
"<system id=\"Mock Server\">\n"+
" <package name=\"aspect\">\n"+
" <aspect class=\"Observer\">\n"+
" <pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/>\n"+
" <advice
name=\"beforeCount\"
type=\"before\" bind-to=\"count\"/>\n"+
" <advice
name=\"afterCount\"
type=\"after\" bind-to=\"count\"/>\n"+
" </aspect>\n"+
" </package>\n"+
" </system>\n"+
"</aspectwerkz>\n";
*/
}
Where the Observer.java aspect and the application (Server.java) to be
weaved is the same as
http://www.nabble.com/Runtime-weaving-question-to20042123.html
The way to test runtime weaving scenario is
1.) launch the server
2.) deploy the aspect by `java -cp
"target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
Post by Alexandre Vasseur
Post by neo anderson
action.Detector 1`
I also have a look at the example in jdk15/test folder, in which it
seems
Post by Alexandre Vasseur
Post by neo anderson
like the hot deployment is done on the same jvm, e.g.
public class HotDeployedTest ...
public void testDeployment() {
...
Deployer.deploy(HotdeployableAspect.class);
target();
...
I think I have done something wrong, but do not know where it is. Would
anyone please give me some hint or advice?
Thank you very much,
Post by Jonas Bonér
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny hooks,
but no aspects). Then you can do hot deploy and undeploy in a running
system.
http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my
scenario
Post by Jonas Bonér
Post by Dongkwan Kim
in
detail.
Suppose there is a running Java application. It don't know
AspectWerkz.
I
Post by Jonas Bonér
Post by Dongkwan Kim
want to insert an aspect into the running application. This is called
the
Post by Jonas Bonér
Post by Dongkwan Kim
remote weaving. Is there any way to weave already running Java
classes?
Post by Jonas Bonér
Post by Dongkwan Kim
DK
--
Jonas Bonér
http://jonasboner.com
--
http://www.nabble.com/remote-weaving--tp13025650p20060099.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
http://www.nabble.com/remote-weaving--tp13025650p20173427.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
neo anderson
2008-10-27 21:49:06 UTC
Permalink
I think I am still confused with the term online weaving.

- How can I send aspect to the (targeted) running process (because hot
deployment required to run in the same JVM)?

- Do I need to startup the target application with socket opened?

Because when using -javaagent option, the terminal throws message

Error occurred during initialization of VM
agent library failed to init: instrument
failed to attach to VM (dt_socket, 9300):
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:204)
at
com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:98)
at
com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:72)
at
org.codehaus.aspectwerkz.hook.ClassLoaderPatcher.hotswapClassLoader(ClassLoaderPatcher.java:205)
at
org.codehaus.aspectwerkz.hook.ProcessStarter.run(ProcessStarter.java:201)
at
org.codehaus.aspectwerkz.hook.ProcessStarter.main(ProcessStarter.java:271)

The way how I run the application is

1st, starting the target application by `java -classpath target sys.Server`
2nd, run the hot deployment `$ASPECTWERKZ_HOME/bin/aspectwerkz
-javaagent:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar -cp
"./:target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`

This looks incorrect, but I completely have no idea where goes wrong.

Would you please to give me advice?

I really appreciate your help.
Post by Alexandre Vasseur
please consider using the javaagent option. That is the best option to
consider in Java 5 / java 6.
On Sun, Oct 26, 2008 at 2:24 PM, neo anderson
Post by neo anderson
After trying several times, I still can not get the online weaving
worked.
I
think there are several things I still do not understand very well.
Mainly it is 'What is the correct way (scenario) to execute the online
weaving?'
From the document at http://aspectwerkz.codehaus.org/downloads/ saying that,
e.g. in transparent bootclasspath mode, running bin/aspectwerkz the first
JVM will launch the application JVM. However, if I switch to run
`$ASPECTWERKZ_HOME/bin/aspectwerkz -cp
"./:target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`
The output will shows some extra information
java ... -Xrunjdwp:transport=dt_socket,suspend=y,address=9300,server=y
-Xdebug -Xbootclasspath/p ...
...
Listening for transport dt_socket at address: 9300
Listening for transport dt_socket at address: 9300
AspectWerkz - INFO - Pre-processor
org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and
initialized
Enable aspect! ...
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
but still there is no aop information weaved to the running server.
Would you please to give me some advice or hints? (Sorry for this newbie
question)
Thanks again for the help. I appreciate it.
Post by Alexandre Vasseur
hot deployment MUST be in the same VM yes. Think deployment (of new
aspect
Post by Alexandre Vasseur
but whose compiled code is already available) as a "runtime weaving"
Amex
On Sun, Oct 19, 2008 at 10:50 PM, neo anderson
Post by neo anderson
I follow the example at
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html
Post by Alexandre Vasseur
Post by neo anderson
to do hot deployment, but it fails. There is no error returned to the
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
The target application does not print out anything.
The code to do deployment is
package action;
public class Detector{
...
void detect(){
System.out.println("Enable aspect! ...");
Deployer.deploy(Observer.class, toXML());
}
...
private String toXML(){
return "<aspect class=\"Observer\"><pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/></aspect>";
/* //this xml throws not well formed xml definition exception
return "<aspectwerkz>\n" +
"<system id=\"Mock Server\">\n"+
" <package name=\"aspect\">\n"+
" <aspect class=\"Observer\">\n"+
" <pointcut
name=\"count\"
Post by Alexandre Vasseur
Post by neo anderson
expression=\"execution(* sys.Server.count(..))\"/>\n"+
" <advice
name=\"beforeCount\"
type=\"before\" bind-to=\"count\"/>\n"+
" <advice
name=\"afterCount\"
type=\"after\" bind-to=\"count\"/>\n"+
" </aspect>\n"+
" </package>\n"+
" </system>\n"+
"</aspectwerkz>\n";
*/
}
Where the Observer.java aspect and the application (Server.java) to be
weaved is the same as
http://www.nabble.com/Runtime-weaving-question-to20042123.html
The way to test runtime weaving scenario is
1.) launch the server
2.) deploy the aspect by `java -cp
"target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
Post by Alexandre Vasseur
Post by neo anderson
action.Detector 1`
I also have a look at the example in jdk15/test folder, in which it
seems
Post by Alexandre Vasseur
Post by neo anderson
like the hot deployment is done on the same jvm, e.g.
public class HotDeployedTest ...
public void testDeployment() {
...
Deployer.deploy(HotdeployableAspect.class);
target();
...
I think I have done something wrong, but do not know where it is.
Would
Post by Alexandre Vasseur
Post by neo anderson
anyone please give me some hint or advice?
Thank you very much,
Post by Jonas Bonér
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny
hooks,
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
but no aspects). Then you can do hot deploy and undeploy in a
running
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
system.
http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my
scenario
Post by Jonas Bonér
Post by Dongkwan Kim
in
detail.
Suppose there is a running Java application. It don't know
AspectWerkz.
I
Post by Jonas Bonér
Post by Dongkwan Kim
want to insert an aspect into the running application. This is
called
Post by Alexandre Vasseur
Post by neo anderson
the
Post by Jonas Bonér
Post by Dongkwan Kim
remote weaving. Is there any way to weave already running Java
classes?
Post by Jonas Bonér
Post by Dongkwan Kim
DK
--
Jonas Bonér
http://jonasboner.com
--
http://www.nabble.com/remote-weaving--tp13025650p20060099.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
http://www.nabble.com/remote-weaving--tp13025650p20173427.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
View this message in context: http://www.nabble.com/remote-weaving--tp13025650p20197173.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Alexandre Vasseur
2008-10-27 22:10:23 UTC
Permalink
online (or runtime) weaving (or dynamic AOP) means weaving when the app is
running and from within the same JVM - in our wording. Often re-weaving is
mimic by simple addition / removal of aspects at pre-determined joinpoints
that have previously been weaved.

The javaagent option does not requires socket or whatever. It is a standard
java (not AOP or whatever related) in java 5+ that can help do class load
time bytecode instrumentation and re-instrumentation. Please don't mix this
one with the aspectwerkz/bin scripts at all.

So steps with AspectWerkz for runtime weaving are:
- add aspectwerkz jar and deps. to your path as per doc
- prepare your jvm startup script for javaagent option use, with proper
syntax for AspectWerkz as in the doc (I think there is a section about this)
- prepare your AspectWerkz xml file for runtime weaving (ie here mostly
declare pre-determined set of joinpoints)
- compile your app, all your aspects, and put everything in the classpath
- start the app. Weaving will happen at class loadtime thanks to javaagent +
xml and aspects that are known (if any, in the xml) will be put in place
- if you want to add/remove an already compiled aspect that is already
available in the classpath at runtime from within the app and apply it to
the set of pre-determined joinpoints you add declared in the xml, then have
your app call the AspectWerkz API for that

I really don't have bandwith to advise further. You may well have a look at
the entire source and the test suite in the project if you don't manage to
get it working.
Alex
Post by neo anderson
I think I am still confused with the term online weaving.
- How can I send aspect to the (targeted) running process (because hot
deployment required to run in the same JVM)?
- Do I need to startup the target application with socket opened?
Because when using -javaagent option, the terminal throws message
Error occurred during initialization of VM
agent library failed to init: instrument
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:204)
at
com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:98)
at
com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:72)
at
org.codehaus.aspectwerkz.hook.ClassLoaderPatcher.hotswapClassLoader(ClassLoaderPatcher.java:205)
at
org.codehaus.aspectwerkz.hook.ProcessStarter.run(ProcessStarter.java:201)
at
org.codehaus.aspectwerkz.hook.ProcessStarter.main(ProcessStarter.java:271)
The way how I run the application is
1st, starting the target application by `java -classpath target sys.Server`
2nd, run the hot deployment `$ASPECTWERKZ_HOME/bin/aspectwerkz
-javaagent:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar -cp
"./:target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
action.Detector 1`
This looks incorrect, but I completely have no idea where goes wrong.
Would you please to give me advice?
I really appreciate your help.
Post by Alexandre Vasseur
please consider using the javaagent option. That is the best option to
consider in Java 5 / java 6.
On Sun, Oct 26, 2008 at 2:24 PM, neo anderson
Post by neo anderson
After trying several times, I still can not get the online weaving
worked.
I
think there are several things I still do not understand very well.
Mainly it is 'What is the correct way (scenario) to execute the online
weaving?'
From the document at http://aspectwerkz.codehaus.org/downloads/ saying that,
e.g. in transparent bootclasspath mode, running bin/aspectwerkz the
first
Post by Alexandre Vasseur
Post by neo anderson
JVM will launch the application JVM. However, if I switch to run
`$ASPECTWERKZ_HOME/bin/aspectwerkz -cp
"./:target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
Post by Alexandre Vasseur
Post by neo anderson
action.Detector 1`
The output will shows some extra information
java ... -Xrunjdwp:transport=dt_socket,suspend=y,address=9300,server=y
-Xdebug -Xbootclasspath/p ...
...
Listening for transport dt_socket at address: 9300
Listening for transport dt_socket at address: 9300
AspectWerkz - INFO - Pre-processor
org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and
initialized
Enable aspect! ...
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
but still there is no aop information weaved to the running server.
Would you please to give me some advice or hints? (Sorry for this newbie
question)
Thanks again for the help. I appreciate it.
Post by Alexandre Vasseur
hot deployment MUST be in the same VM yes. Think deployment (of new
aspect
Post by Alexandre Vasseur
but whose compiled code is already available) as a "runtime weaving"
Amex
On Sun, Oct 19, 2008 at 10:50 PM, neo anderson
Post by neo anderson
I follow the example at
http://blogs.codehaus.org/people/jboner/archives/000913_aspect_hot_deployment_in_practice_implementing_a_jmx_monitoring_aspect_.html
Post by Alexandre Vasseur
Post by neo anderson
Post by Alexandre Vasseur
Post by neo anderson
to do hot deployment, but it fails. There is no error returned to the
Deployer::INFO - deploying aspect [aspect.Observer] in class loader
The target application does not print out anything.
The code to do deployment is
package action;
public class Detector{
...
void detect(){
System.out.println("Enable aspect! ...");
Deployer.deploy(Observer.class, toXML());
}
...
private String toXML(){
return "<aspect class=\"Observer\"><pointcut name=\"count\"
expression=\"execution(* sys.Server.count(..))\"/></aspect>";
/* //this xml throws not well formed xml definition exception
return "<aspectwerkz>\n" +
"<system id=\"Mock Server\">\n"+
" <package name=\"aspect\">\n"+
" <aspect
class=\"Observer\">\n"+
Post by Alexandre Vasseur
Post by neo anderson
Post by Alexandre Vasseur
Post by neo anderson
" <pointcut
name=\"count\"
Post by Alexandre Vasseur
Post by neo anderson
expression=\"execution(* sys.Server.count(..))\"/>\n"+
" <advice
name=\"beforeCount\"
type=\"before\" bind-to=\"count\"/>\n"+
" <advice
name=\"afterCount\"
type=\"after\" bind-to=\"count\"/>\n"+
" </aspect>\n"+
" </package>\n"+
" </system>\n"+
"</aspectwerkz>\n";
*/
}
Where the Observer.java aspect and the application (Server.java) to
be
Post by Alexandre Vasseur
Post by neo anderson
Post by Alexandre Vasseur
Post by neo anderson
weaved is the same as
http://www.nabble.com/Runtime-weaving-question-to20042123.html
The way to test runtime weaving scenario is
1.) launch the server
2.) deploy the aspect by `java -cp
"target:$ASPECTWERKZ_HOME/lib/aspectwerkz-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-core-2.0.jar:$ASPECTWERKZ_HOME/lib/aspectwerkz-extensions-2.0.jar"
Post by Alexandre Vasseur
Post by neo anderson
Post by Alexandre Vasseur
Post by neo anderson
action.Detector 1`
I also have a look at the example in jdk15/test folder, in which it
seems
Post by Alexandre Vasseur
Post by neo anderson
like the hot deployment is done on the same jvm, e.g.
public class HotDeployedTest ...
public void testDeployment() {
...
Deployer.deploy(HotdeployableAspect.class);
target();
...
I think I have done something wrong, but do not know where it is.
Would
Post by Alexandre Vasseur
Post by neo anderson
anyone please give me some hint or advice?
Thank you very much,
Post by Jonas Bonér
Yes it is possible, but you will have to define a so-called
'deployment scope' and preweave the classes (will just add tiny
hooks,
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
but no aspects). Then you can do hot deploy and undeploy in a
running
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
system.
http://aspectwerkz.codehaus.org/new_features_in_2_0.html#Hot_deployment_and_undeployment_of_aspects
Post by Alexandre Vasseur
Post by neo anderson
Post by Alexandre Vasseur
Post by neo anderson
Post by Jonas Bonér
/Jonas
Post by Dongkwan Kim
Does AspectWerkz support the remote weaving? Let me explain my
scenario
Post by Jonas Bonér
Post by Dongkwan Kim
in
detail.
Suppose there is a running Java application. It don't know
AspectWerkz.
I
Post by Jonas Bonér
Post by Dongkwan Kim
want to insert an aspect into the running application. This is
called
Post by Alexandre Vasseur
Post by neo anderson
the
Post by Jonas Bonér
Post by Dongkwan Kim
remote weaving. Is there any way to weave already running Java
classes?
Post by Jonas Bonér
Post by Dongkwan Kim
DK
--
Jonas Bonér
http://jonasboner.com
--
http://www.nabble.com/remote-weaving--tp13025650p20060099.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
http://www.nabble.com/remote-weaving--tp13025650p20173427.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
--
http://www.nabble.com/remote-weaving--tp13025650p20197173.html
Sent from the AspectWerkz - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
s***@yahoo.com
2008-12-11 02:37:05 UTC
Permalink
Hi guys,

I was hoping if someone could tell me if a fix has already been put in for the java deadlock issue with WeakHashMap(). it seems to be a known issue based on what I've been able to research so far.

The fix seems to be to replace <code>WeakHashMap()</code> with <code>Collections.synchronizedMap(new WeakHashMap())</code>

I would be glad to fix it myself and rebuilding AspectWerkz if I have to, but I'd prefer to use an official distribution.

Thank you.

Axel

Weblogic 9 log is shown below:

Found one Java-level deadlock:

=============================

"[STANDBY] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'":

waiting to lock monitor 0x00258e48 (object 0x75810818, a java.util.WeakHashMap),

which is held by "[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'"

"[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'":

waiting to lock monitor 0x00258bc0 (object 0x758000b0, a sun.misc.Launcher$AppClassLoader),

which is held by "[STANDBY] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'"



Java stack information for the threads listed above:

===================================================

"[STANDBY] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'":

at org.codehaus.aspectwerkz.definition.SystemDefinitionContainer.getHierarchicalDefinitionsFor(SystemDefinitionContainer.java:311)

- waiting to lock <0x75810818> (a java.util.WeakHashMap)

at org.codehaus.aspectwerkz.definition.SystemDefinitionContainer.getDefinitionsFor(SystemDefinitionContainer.java:225)

at org.codehaus.aspectwerkz.transform.inlining.ContextImpl.<init>(ContextImpl.java:99)

at org.codehaus.aspectwerkz.transform.inlining.InliningWeavingStrategy.newContext(InliningWeavingStrategy.java:259)

at org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor._preProcess(AspectWerkzPreProcessor.java:166)

at org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor.preProcess(AspectWerkzPreProcessor.java:148)

at com.intersperse.instrumentation.weblogic.WeblogicClassPreprocessor.preProcess(WeblogicClassPreprocessor.java:82)

at org.codehaus.aspectwerkz.hook.PreProcessorAdapter.transform(PreProcessorAdapter.java:50)

at sun.instrument.TransformerManager.transform(TransformerManager.java:122)

at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)

at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

- locked <0x758000b0> (a sun.misc.Launcher$AppClassLoader)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

- locked <0x758000b0> (a sun.misc.Launcher$AppClassLoader)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

- locked <0x758000b0> (a sun.misc.Launcher$AppClassLoader)

at weblogic.cluster.MulticastSender.isHeartbeatMessage(MulticastSender.java:306)

at weblogic.cluster.MulticastSender.prepare(MulticastSender.java:279)

at weblogic.cluster.MulticastSender.send(MulticastSender.java:156)

- locked <0x7651c598> (a weblogic.cluster.MulticastSender)

at weblogic.cluster.AttributeManager.sendAttributes(AttributeManager.java:46)

at weblogic.cluster.OutboundService.start(OutboundService.java:33)

at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)

at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)

at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)

"[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'":

at weblogic.utils.io.FilenameEncoder.getSafeFile0(FilenameEncoder.java:244)

at weblogic.utils.io.FilenameEncoder.getSafeFile(FilenameEncoder.java:165)

at weblogic.utils.classloaders.DirectoryClassFinder.getSource(DirectoryClassFinder.java:35)

at weblogic.utils.classloaders.JarClassFinder.getSource(JarClassFinder.java:45)

at weblogic.utils.classloaders.MultiClassFinder.getSource(MultiClassFinder.java:67)

at weblogic.utils.classloaders.MultiClassFinder.getSource(MultiClassFinder.java:67)

at weblogic.utils.classloaders.MultiClassFinder.getSource(MultiClassFinder.java:67)

at weblogic.utils.classloaders.MultiClassFinder.getSource(MultiClassFinder.java:67)

at weblogic.application.utils.CompositeWebAppFinder.getSource(CompositeWebAppFinder.java:71)

at weblogic.utils.classloaders.MultiClassFinder.getSource(MultiClassFinder.java:67)

at weblogic.utils.classloaders.MultiClassFinder.getSource(MultiClassFinder.java:67)

at weblogic.utils.classloaders.CodeGenClassFinder.getSource(CodeGenClassFinder.java:33)

at weblogic.utils.classloaders.GenericClassLoader.findResource(GenericClassLoader.java:209)

at weblogic.utils.classloaders.GenericClassLoader.getResourceInternal(GenericClassLoader.java:161)

at weblogic.utils.classloaders.GenericClassLoader.getResource(GenericClassLoader.java:187)

at weblogic.utils.classloaders.ChangeAwareClassLoader.getResource(ChangeAwareClassLoader.java:112)

at org.codehaus.aspectwerkz.definition.SystemDefinitionContainer.registerClassLoader(SystemDefinitionContainer.java:121)

- locked <0x75810818> (a java.util.WeakHashMap)

at org.codehaus.aspectwerkz.definition.SystemDefinitionContainer.getHierarchicalDefinitionsFor(SystemDefinitionContainer.java:317)

- locked <0x75810818> (a java.util.WeakHashMap)

at org.codehaus.aspectwerkz.definition.SystemDefinitionContainer.getDefinitionsFor(SystemDefinitionContainer.java:225)

at org.codehaus.aspectwerkz.transform.inlining.ContextImpl.<init>(ContextImpl.java:99)

at org.codehaus.aspectwerkz.transform.inlining.InliningWeavingStrategy.newContext(InliningWeavingStrategy.java:259)

at org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor._preProcess(AspectWerkzPreProcessor.java:166)

at org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor.preProcess(AspectWerkzPreProcessor.java:148)

at com.intersperse.instrumentation.weblogic.WeblogicClassPreprocessor.preProcess(WeblogicClassPreprocessor.java:82)

at org.codehaus.aspectwerkz.hook.PreProcessorAdapter.transform(PreProcessorAdapter.java:50)

at sun.instrument.TransformerManager.transform(TransformerManager.java:122)

at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:338)

at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:291)

- locked <0x3ae890b8> (a weblogic.utils.classloaders.ChangeAwareClassLoader)

at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:259)

at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)

- locked <0x3ae890b8> (a weblogic.utils.classloaders.ChangeAwareClassLoader)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

- locked <0x3ae890b8> (a weblogic.utils.classloaders.ChangeAwareClassLoader)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)

at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)

- locked <0x3ae890b8> (a weblogic.utils.classloaders.ChangeAwareClassLoader)

at weblogic.servlet.internal.WebAnnotationProcessorImpl.processAnnotations(WebAnnotationProcessorImpl.java:76)

at weblogic.servlet.internal.WebAppServletContext.processAnnotations(WebAppServletContext.java:1270)

at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:408)

at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:452)

at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:402)

- locked <0x75c61a28> (a weblogic.servlet.internal.HttpServer)

at weblogic.servlet.internal.WebAppModule.registerWebApp(WebAppModule.java:582)

at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:298)

at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)

at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)

at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:360)

at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)

at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:56)

at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:46)

at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)

at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)

at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)

at weblogic.application.internal.BackgroundDeploymentService$1.next(BackgroundDeploymentService.java:164)

at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)

at weblogic.application.internal.BackgroundDeploymentService$BackgroundDeployAction.run(BackgroundDeploymentService.java:119)

at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)

at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)

at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)

Loading...