Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Query Regarding Maven Aspectj

Hi,

It isn't clear to me when you are wanting the aspects to be woven in?

Are you doing compile time weaving (looks like you might be)?  In this
mode you can  just run the result with 'java', you don't need to see
javaagent.

Are you doing loadtime weaving? (where the aspects are separate to the
basecode and you want them applied as the application loads).  I don't
see the separate builds of basecode and aspects in the pom, but I do
see the javaagent being set for loadtime weaving.

If you are loadtime weaving you will need an aop.xml. Which you can
generate or write yourself, it simply lists the aspects:
<aspectj>
<aspects>
<aspect name="MyAspect"/>
</aspects>
</aspectj>
and will be looked up through your classpath (weaver expects to find
it in a META-INF subfolder).

Is your app code in app.jar?  If so, where are your aspects on the
classpath when you run it?  If they are also in app.jar and it was all
woven at compile time, just don't use the agent setting.

But I guess it comes down to my first question - do you want to weave
at compile time or later?  You have the choice.

cheers,
Andy

On 9 April 2012 00:23, arun viswanath <arun.viswanath@xxxxxxxxx> wrote:
> Hi Andy,
>
> Thanks for your quick response.
> I'm pasting my pom contents below.
>
> <build>
>       <plugins>
>            <plugin>
>                   <groupId>org.codehaus.mojo</groupId>
>                   <artifactId>aspectj-maven-plugin</artifactId>
>                   <version>1.4</version>
>                   <configuration>
>                     <source>1.6</source>
>                     <target>1.6</target>
>                    </configuration>
>                     <executions>
>                       <execution>
>                         <goals>
>                            <goal>compile</goal>       <!-- use this goal to
> weave all your main classes -->
>                            <goal>test-compile</goal>  <!-- use this goal to
> weave all your test classes -->
>                         </goals>
>                       </execution>
>                     </executions>
>                 </plugin>
>             <plugin>
>          </plugins>
> </build>
>
> Any my application start command is
>
> nohup java -Xms1024M -Xmx2048M
> -Djava.util.logging.config.file=$PRJ_HOME/conf/log.properties -jar
>  -classpath $PRJ_HOME/lib/jars/aspectjrt-1.6.11.jar
> -javaagent:$PRJ_HOME/lib/jars/aspectjweaver.jar
> -Dorg.apache.activemq.UseDedicatedTaskRunner=true $PRJ_HOME/lib/jars/app.jar
>  >$START_STATUS 2>&1 &
>
> I'm missing some thing here no able to spot it.
>
> Your help will be really appreciated.
>
> Arun.
>
>
>
> On Sat, Apr 7, 2012 at 5:02 AM, Andy Clement <andrew.clement@xxxxxxxxx>
> wrote:
>>
>> Hi Arun,
>>
>> You should just be able to run the code after your build finishes.  I
>> presume you were doing a regular build of aspects and java source
>> code, to produce a woven result.  You weren't load time weaving?
>>
>> The only requirement for running woven code is that you have the
>> aspectj runtime (aspectjrt.jar) on the classpath when you run java.
>>
>> If you are loadtime weaving then you may need to use the javaagent
>> when you run the code
>> (-javaagent:<pathtoaspectj>/lib/aspectjweaver.jar) but that is only
>> required if the java source and aspects have been compiled separately.
>>
>> Maybe if you show me your pom I can puzzle it out.
>>
>> cheers,
>> Andy
>>
>> On 5 April 2012 22:28, arun viswanath <arun.viswanath@xxxxxxxxx> wrote:
>> > Hi,
>> >
>> > This is Arun. I’m using AspectJ in my project. My project is based on
>> > Maven.
>> >
>> > I’m able to successfully compile the .aj file and when I try to run the
>> > testcase using maven my aspects are working fine.
>> >
>> >
>> >
>> > But when I start executing the program from command prompt (eg.. java
>> > <*.jar>) my aspects are not working. Is it necessary to set any Java JVM
>> > option for my aspect to execute.
>> >
>> >
>> >
>> > Thanks In Advance,
>> >
>> > Arun V
>> >
>> >
>> > _______________________________________________
>> > aspectj-dev mailing list
>> > aspectj-dev@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>> >
>> _______________________________________________
>> aspectj-dev mailing list
>> aspectj-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
>
>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>


Back to the top