Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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@xxxxxxxxxxx
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

..................................................



Back to the top