0

I have created an executable jar of my scala application. I am trying to use AspectJ Load-Time-Weaving. The aspectj is working as expected, however, it is taking a huge amount of time to start the jar file after the LTW.

My AOP.xml is as below:

<aspectj>
    <aspects>
        <aspect name="com.app.module.aspect.WorkflowInterceptor"/>
    </aspects>

    <weaver options="-verbose">
        <dump within="com.app.*"/>
        <!--<include within="com.app.common.features..*"/>-->
    </weaver>

</aspectj>

When I run the jar file as

java -javaagent:aspectjweaver-1.8.4.jar -jar myapp.jar

The jar file starts after 15 min, sometime even 30 min. I tried to reduce the aspectj weaving by using include but not working. If I do not provide dump, the aspect is not getting invoked at all.

Can anyone help me to solve this issue ?

EDIT: I removed the <dump> and used <include within ..>. It is working, but still taking a lot of time (5 min )

Yadu Krishnan
  • 3,492
  • 5
  • 41
  • 80
  • -javaagent:aspectjweaver-1.8.4.jar makes it compile time weaving. So you're weaving twice I think. I never had to use dump advice to make it work. – Jazzwave06 Mar 10 '15 at 15:14
  • @sturcotte06 how is it compile time weaving? javaagent is used while loading/running the jar right? – Yadu Krishnan Mar 10 '15 at 15:23
  • Are you using spring? If I remember correctly, you need to specify a special ClassLoader for load time weaving. The java agent is the special compiler that rewrite your code at compile time (compile time weaving). – Jazzwave06 Mar 10 '15 at 15:24
  • no, i m not using spring. My app is in scala. – Yadu Krishnan Mar 10 '15 at 15:27
  • 1
    "In addition the dump element can be used capture on disk byte-code of woven classes for diagnostic purposes both before, in the case of those generated at runtime, and after the weaving process." You don't need that. Also, I just read that the class loader is included in the java agent. I guess it's ok to specify it like you do. – Jazzwave06 Mar 10 '15 at 15:27
  • Add the -showWeaveInfo flag into your weaver's options. – Jazzwave06 Mar 10 '15 at 15:30
  • Thanks. Let me try that. If I remember correctly, I tried removing dump, and added include, but was getting some issues. Dont remember exactly as I have tried out many different things. – Yadu Krishnan Mar 10 '15 at 15:32
  • I removed dump and added include. It is working as expected, but it is taking almost 5 min to start the jar file. – Yadu Krishnan Mar 11 '15 at 05:39
  • It's because you're weaving too much. How many classe are contained within the packages starting with com.app – Jazzwave06 Mar 11 '15 at 15:20
  • Yeah, there are too many classes. I tried to reduce the scope by giving multiple include statements, for some reasons it was not weaving at all. I can give multiple include lines in aop.xml, right ? – Yadu Krishnan Mar 12 '15 at 03:52
  • Yes, you can. Be the more precise possible. – Jazzwave06 Mar 12 '15 at 14:57
  • Provide an [SSCCE](http://sscce.org/), please. Maven project on GitHub is preferred. Or at least show us your aspect(s) and provide us with a few numerics such as the number of classes in your `com.app` package (incl. subpackages). – kriegaex Mar 16 '15 at 19:52

0 Answers0