Re: [aspectj-users] Post-compile time weaving: howto
Not having read the thread, just noticing that question, let me say this: whichever class comes first in the classpath of any given classloader will be found and loaded. Others will be ignored, and there will be no "re-loading" of already defined classes. Disclaimer: You can create a new classloader and load a class with the same package and class name in an isolated "container", but that is another story. -- Alexander Kriegisch Am 11.09.2012 um 08:51 schrieb Valerian Galeru : >> What about class name conflict: how decides JVM which class to take (it will >> be one in the WebApplication and another in the woven exported jar file)? >> Won't the virtual machine complain, that there are two .class file with the >> same name? ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users
Re: [aspectj-users] Post-compile time weaving: howto
What about class name conflict: how decides JVM which class to take (it will be one in the WebApplication and another in the woven exported jar file)? Won't the virtual machine complain, that there are two .class file with the same name? Am 04.09.2012 19:42, schrieb Andy Clement: Questions In the exported aspect-jar, there are only the .class files of the AspectJ project, no .class files for the INPATH-Jar. Should there be other classes, from the imported INPATH-jar? I can imagine 'export jar with AspectJ support' is not totally inpath aware in the simple case. But I just tried using it and ticked the second option 'Export all output folders for checked projects' rather than leaving the first option checked on the wizard and it worked fine. My output jar contains woven material from the inpath. In the exported aspect-jar there is no jar with the aspectj-runtime (aspectj-rt.jar). Should it be there, or how to configure the virtual machine to have it? Usually just put it on the classpath alongside your app (package it alongside other app libs in your war file, for example). Is post-compile weaving the way to do it, or whould I use the Load-time weaving? It is a trade off - loadtime weaving gives you a bit more flexibility (you can change the aop.xml and restart to add/remove aspects) but you suffer a startup hit for that flexibility. Post compile weaving (binary weaving) doesn't have that flexibility but there is no startup hit. Andy. On 4 September 2012 05:35, Valerian Galeru wrote: Hello, I have a Web application with a Plugin System, which actually runs in a Tomcat. I want to control/change the behaviour of the Web Application. I thought, having the JAR's of the Web Application, it would be no problem to use the Post-compile weaving of the AspectJ. I tried to weave some classes in a JAR this way (in Eclipse): In the AspectJ Project I added the jar file to the INPATH, where the classes to be woven are. Exported the Project as "Jar with AspectJ support" Deployed the jar file exported at the step 2: No result. Questions: In the exported aspect-jar, there are only the .class files of the AspectJ project, no .class files for the INPATH-Jar. Should there be other classes, from the imported INPATH-jar? In the exported aspect-jar there is no jar with the aspectj-runtime (aspectj-rt.jar). Should it be there, or how to configure the virtual machine to have it? Is post-compile weaving the way to do it, or whould I use the Load-time weaving? ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users
Re: [aspectj-users] Post-compile time weaving: howto
> Questions > In the exported aspect-jar, there are only the .class files of the AspectJ > project, no .class files for the INPATH-Jar. Should there be other classes, > from the imported INPATH-jar? I can imagine 'export jar with AspectJ support' is not totally inpath aware in the simple case. But I just tried using it and ticked the second option 'Export all output folders for checked projects' rather than leaving the first option checked on the wizard and it worked fine. My output jar contains woven material from the inpath. > In the exported aspect-jar there is no jar with the aspectj-runtime > (aspectj-rt.jar). Should it be there, or how to configure the virtual > machine to have it? Usually just put it on the classpath alongside your app (package it alongside other app libs in your war file, for example). > Is post-compile weaving the way to do it, or whould I use the Load-time > weaving? It is a trade off - loadtime weaving gives you a bit more flexibility (you can change the aop.xml and restart to add/remove aspects) but you suffer a startup hit for that flexibility. Post compile weaving (binary weaving) doesn't have that flexibility but there is no startup hit. Andy. On 4 September 2012 05:35, Valerian Galeru wrote: > Hello, > > I have a Web application with a Plugin System, which actually runs in a > Tomcat. I want to control/change the behaviour of the Web Application. I > thought, having the JAR's of the Web Application, it would be no problem to > use the Post-compile weaving of the AspectJ. > > I tried to weave some classes in a JAR this way (in Eclipse): > > In the AspectJ Project I added the jar file to the INPATH, where the classes > to be woven are. > Exported the Project as "Jar with AspectJ support" > Deployed the jar file exported at the step 2: No result. > > Questions: > > In the exported aspect-jar, there are only the .class files of the AspectJ > project, no .class files for the INPATH-Jar. Should there be other classes, > from the imported INPATH-jar? > In the exported aspect-jar there is no jar with the aspectj-runtime > (aspectj-rt.jar). Should it be there, or how to configure the virtual > machine to have it? > Is post-compile weaving the way to do it, or whould I use the Load-time > weaving? > > > ___ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users > ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users
Re: [aspectj-users] Post-compile time weaving: howto
Hi Alexander, Thank you for your answer&help. I tried also with "Runnable JAR" + "Package required libraries into generated JAR". Now all the JARs in the Build Path (+ aspectj-rt.jar + the JAR in the INPATH) are included in the root of the exported JAR. As compiled classes it has these additional classes (beside MyAspect.class and a MyPlugin.class) org/eclipse/jdt/internal/jarinjarloader/JIJConstants.class org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader$ManifestInfo.class org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.class org/eclipse/jdt/internal/jarinjarloader/RsrcURLConnection.class org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandler.class org/eclipse/jdt/internal/jarinjarloader/RsrcURLStreamHandlerFactory.class But it has no effect on the external INPATH-JAR (it should occur an RuntimeException). Besides this I noticed another problem with this solution: the MyAspect.class advises also a method doDefault() in MyPlugin.class. When doDefault() gets called, an the following error occures: Caused by: java.lang.ClassNotFoundException: org.aspectj.runtime.internal.AroundClosure at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772) at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690) at java.lang.ClassLoader.loadClass(ClassLoader.java:247). My Aspect is the following: pointcut aroundAsdCall():execution(String MyPlugin.doDefault()); Object around():aroundAsdCall() { throw new RuntimeException("YES"); //return proceed(); } Also I tried another solution (beside that one with Runnable Jar): to export the Project as a "Jar with Aspectj support", in which the META-INF/lib/ folder contains the aspectj-rt.jar & the weaver. In this situation, MyPlugin gets advised, but the INPATH-JAR still not. Any further ideas? Thank you in advance. Am 04.09.2012 17:08, schrieb Alexander Kriegisch: Hi Valerian! I guess we met earlier there (same topic): http://stackoverflow.com/questions/12104735/aspectj-controlling-calls-in-other-jars As I said, I would also have expected "JAR with AJ" export to include necessary dependencies, this looks like a bug. So it is good to bring it to the developers' attention. Maybe you should file a ticket in Bugzilla (http://www.eclipse.org/ajdt/bugs.php). But I also gave you a workaround (quoting myself): Try "Runnable JAR file" with sub-option "Package required libraries into generated JAR". It will contain the necessary libraries. As a little trick you might need to create a dummy main method for one aspect and create a Java run configuration for it which you need to select during export so as to get to the next page of the export assistant. Just to make sure that there is nothing else wrong in your classes and aspects: Does it work using this trick? Because basically what you want to do is possible. And just to double-check: You want to weave the application with 'execution' pointcuts, right? Not the plugins with 'call' pointcuts. (That would also be possible, but somewhat more tricky and probably not necessary for you.) -- Alexander Kriegisch Valerian Galeru, 04.09.2012 14:35: I have a Web application with a Plugin System, which actually runs in a Tomcat. I want to control/change the behaviour of the Web Application. I thought, having the JAR's of the Web Application, it would be no problem to use the Post-compile weaving of the AspectJ. I tried to weave some classes in a JAR this way (in Eclipse): * In the AspectJ Project I added the jar file to the INPATH, where the classes to be woven are. * Exported the Project as "Jar with AspectJ support" * Deployed the jar file exported at the step 2: No result. Questions: 1. In the exported aspect-jar, there are only the .class files of the AspectJ project, no .class files for the INPATH-Jar. Should there be other classes, from the imported INPATH-jar? 2. In the exported aspect-jar there is no jar with the aspectj-runtime (aspectj-rt.jar). Should it be there, or how to configure the virtual machine to have it? 3. Is post-compile weaving the way to do it, or whould I use the Load-time weaving? ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users -- .. Valerian Galeru Softwareentwickler Interconcept GmbH Zum Quellenpark 38 D-65812 Bad Soden fon +49 (0)6196 88776-230 fax +49 (0)6196 88776-290 www.interconcept.de Sitz der Gesellschaft: Bad Soden Amtsgericht Koenigstein HRB 4705 Geschaeftsfuehrer: R. Lopinski, T. Reibling .. ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-
Re: [aspectj-users] Post-compile time weaving: howto
Hi Valerian! I guess we met earlier there (same topic): http://stackoverflow.com/questions/12104735/aspectj-controlling-calls-in-other-jars As I said, I would also have expected "JAR with AJ" export to include necessary dependencies, this looks like a bug. So it is good to bring it to the developers' attention. Maybe you should file a ticket in Bugzilla (http://www.eclipse.org/ajdt/bugs.php). But I also gave you a workaround (quoting myself): >> Try "Runnable JAR file" with sub-option "Package required libraries >> into generated JAR". It will contain the necessary libraries. As a >> little trick you might need to create a dummy main method for one >> aspect and create a Java run configuration for it which you need to >> select during export so as to get to the next page of the export >> assistant. Just to make sure that there is nothing else wrong in your classes and aspects: Does it work using this trick? Because basically what you want to do is possible. And just to double-check: You want to weave the application with 'execution' pointcuts, right? Not the plugins with 'call' pointcuts. (That would also be possible, but somewhat more tricky and probably not necessary for you.) -- Alexander Kriegisch Valerian Galeru, 04.09.2012 14:35: > I have a Web application with a Plugin System, which actually runs in a > Tomcat. I want to control/change the behaviour of the Web Application. I > thought, having the JAR's of the Web Application, it would be no problem > to use the Post-compile weaving of the AspectJ. > > I tried to weave some classes in a JAR this way (in Eclipse): > > * In the AspectJ Project I added the jar file to the INPATH, where the > classes to be woven are. > * Exported the Project as "Jar with AspectJ support" > * Deployed the jar file exported at the step 2: No result. > > Questions: > > 1. In the exported aspect-jar, there are only the .class files of the > AspectJ project, no .class files for the INPATH-Jar. Should there be > other classes, from the imported INPATH-jar? > 2. In the exported aspect-jar there is no jar with the aspectj-runtime > (aspectj-rt.jar). Should it be there, or how to configure the > virtual machine to have it? > 3. Is post-compile weaving the way to do it, or whould I use the > Load-time weaving? ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users
[aspectj-users] Post-compile time weaving: howto
Hello, I have a Web application with a Plugin System, which actually runs in a Tomcat. I want to control/change the behaviour of the Web Application. I thought, having the JAR's of the Web Application, it would be no problem to use the Post-compile weaving of the AspectJ. I tried to weave some classes in a JAR this way (in Eclipse): * In the AspectJ Project I added the jar file to the INPATH, where the classes to be woven are. * Exported the Project as "Jar with AspectJ support" * Deployed the jar file exported at the step 2: No result. Questions: 1. In the exported aspect-jar, there are only the .class files of the AspectJ project, no .class files for the INPATH-Jar. Should there be other classes, from the imported INPATH-jar? 2. In the exported aspect-jar there is no jar with the aspectj-runtime (aspectj-rt.jar). Should it be there, or how to configure the virtual machine to have it? 3. Is post-compile weaving the way to do it, or whould I use the Load-time weaving? ___ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users