Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] FW: NoSuchMethodError: aspectOf()

Hi Andy,

Thank you very much for looking at my problem.

Yes I included the aspect in my call to iajc.

Below is a portion of my build.xml (target Pdm.war) and the output of “ant Pdm.war”.

Login.java is my aspect expressed in @AspectJ notation.

 

            <target name="Pdm.war" depends="prepare">

                        <!-- compile core concern classes -->

                        <javac

                                    srcdir   ="${dir.dm}/src"

                                    destdir ="${dir.build}/java/classes">

                                    <classpath>

                                                <fileset dir="${dir.dm}/lib" includes="*.jar"/>

                                                <fileset dir="${dir.dm}/lib/crystal">

                                                            <include name="CrystalCommon2.jar"/>

                                                            <include name="CrystalReportsRuntime.jar"/>

                                                </fileset>

                                                <fileset file="${dir.build}/servlet.jar"/>

                                    </classpath>

                        </javac>

                       

                        <!-- jar the core concern classes -->

                        <jar

                                    basedir            ="${dir.build}/java/classes"

                                    destfile="${dir.build}/java/DMCoreConcerns.jar"                            

                        />

                       

                        <!-- compile the aspect classes -->

                        <javac                         

                                    srcdir   ="${dir.dm}/src-aspects-aspectj"

                                    destdir ="${dir.build}/aspects/classes/"

                                    debug  ="true"            >                                                                                             

                                    <classpath>

                                                <fileset dir="${log4j.dir}">

                                                            <include name="log4j-1.2.8.jar"/>

                                                </fileset>

                                                <pathelement location="${dir.build}/java/DMCoreConcerns.jar"/>

                                    </classpath>

                        </javac>

                        <!-- jar the aspect classes -->

                        <jar

                                    basedir            ="${dir.build}/aspects/classes"

                                    destfile="${dir.build}/aspects/DMAspects.jar"                                 

                        />                    

                        <!-- Weave the core concern classes with the aspects -->

                        <aspectj:iajc

                                    inpath              ="${dir.build}/java/classes"

                                    aspectPath      ="${dir.build}/aspects/DMAspects.jar"

                                    destDir            ="${dir.build}/WEB-INF/classes"

                                    classpath         ="${aspectj.lib.dir}/aspectjrt.jar"

                                    source             ="1.5"

                                    XlintFile           ="${dir.build}/xlint.properties"

                                    verbose           ="true"

                                    showWeaveInfo="true"

                        />                    

                        <!-- Create the war -->

                        <jar jarfile="${dir.dist}/PdmWar/Pdm.war">

                                    <fileset            dir="${dir.dm}/WebFiles"/>

                                    <zipfileset dir="${dir.dm}/lib" prefix="WEB-INF/lib">

                                                <include name="*.jar"/>

                                                <include name="*.zip"/>

                                                <exclude name="sapjco.*"/>

                                    </zipfileset>

                                    <zipfileset dir="${dir.dm}/lib/crystal"            prefix="WEB-INF/lib"/>

                                    <zipfileset dir="${dir.dm}/config"                  prefix="WEB-INF/classes"/>

                                    <zipfileset dir="${dir.mappingFiles}" prefix="WEB-INF/classes">

                                                <patternset refid="bundledMappingFiles"/>

                                                <include name="DST*.xsd"/>

                                    </zipfileset>

                                    <zipfileset dir="${dir.dm}/PropertyFile" prefix="WEB-INF/classes"/>

                                    <zipfileset dir="${dir.dm}/src"                        prefix="WEB-INF/classes" includes="**/*.properties"/>

                                    <fileset            dir="${dir.build}"                                 includes="WEB-INF/"/>

                                    <fileset            dir="${dir.build}/aspects"       includes="DMAspects.jar"/>

                                    <zipfileset dir="${dir.build}/aspects/classes" prefix="WEB-INF/classes"/>

                        </jar>

            </target>        

Buildfile: build.xml

     [echo] Release build for Windows XP.

 

init:

 

prepare:

 

Pdm.war:

[aspectj:iajc] ajc [-d, C:\DataManager\Trunk\build\WEB-INF\classes, -source, 1.5, -Xlintfile, C:\DataManager\Trunk\build\xlint.properties, -verbose, -showWeaveInfo, -classpath, C:\Program Files\aspectj1.6\lib\aspectjrt.jar, -aspectpath, C:\DataManager\Trunk\build\aspects\DMAspects.jar, -inpath, C:\DataManager\Trunk\build\java\classes]

[aspectj:iajc] info directory classpath entry does not exist: C:\Program Files\Java\jdk1.5.0_20\jre\lib\i18n.jar

[aspectj:iajc] info directory classpath entry does not exist: C:\Program Files\Java\jdk1.5.0_20\jre\lib\sunrsasign.jar

[aspectj:iajc] info zipfile classpath entry does not exist: C:\Program Files\Java\jdk1.5.0_20\jre\classes

[aspectj:iajc] info Pipelining compilation

[aspectj:iajc] info weaver operating in reweavable mode.  Need to verify any required types exist.

 

[aspectj:iajc] weaveinfo Join point 'method-call(com.foo.athens.beans.LoginData com.foo.athens.dao.LoginDAO.login(com.foo.athens.beans.LoginData))' in Type 'com.foo.athens.action.LoginAction' (no debug info available) advised by before advice from 'com.foo.logging.Login' (DMAspects.jar!Login.class(from Login.java))

[aspectj:iajc] weaveinfo Join point 'method-call(com.foo.athens.beans.LoginData com.foo.athens.dao.LoginDAO.login(com.foo.athens.beans.LoginData))' in Type 'com.foo.athens.action.LoginAction' (no debug info available) advised by after advice from 'com.foo.logging.Login' (DMAspects.jar!Login.class(from Login.java))

[aspectj:iajc] weaveinfo Join point 'method-call(com.foo.athens.beans.LoginData com.foo.athens.dao.LoginDAO.login(com.foo.athens.beans.LoginData))' in Type 'com.foo.athens.action.LoginAction' (no debug info available) advised by afterThrowing advice from 'com.foo.logging.Login' (DMAspects.jar!Login.class(from Login.java))

[aspectj:iajc] info woven class com.foo.athens.action.LoginAction (from C:\DataManager\Trunk\build\java\classes\com\foo\athens\action\LoginAction.class)

[aspectj:iajc] info Compiler took 3813ms

[jar] Building jar: C:\DataManager\Trunk\Install\DataManager\PdmWar\Pdm.war

 

BUILD SUCCESSFUL

Total time: 9 seconds

 

 

Thanks,

Roger Huang

 

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
Sent: Friday, October 30, 2009 5:32 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] FW: NoSuchMethodError: aspectOf()

 

Hi Roger,

 

Are you definetly including the aspect itself in the call to iajc?

Annotation style aspects (when @Pointcut/etc are used) can be compiled

with javac, but they must be given to the weaver at some point in

order for the missing methods to be added - for example 'aspectOf()'.

 

cheers,

Andy

 

2009/10/30 Roger Huang <rhuang@xxxxxxxxxxxxxxx>:

> Any ideas why I am get the NoSuchMethodError below?

> 

> 

> 

> The method specified by the pointcut is in

> com.foo.action.LoginAction.execute.

> 

> The aspect is defined in com.foo.logging.Login.   (see below)

> 

> My code which is being advised does not call the aspect’s aspectOf() method.

> 

> 

> 

> I use build-time bytecode weaving using the ant <iajc> task.

> 

> 

> 

> The app is a Struts-based web app.

> 

> 

> 

> 

> 

> Dev environment:

> 

> Java 1.5

> 

> Ant 1.7.1

> 

> AspectJ 1.6.6

> 

> 

> 

> Thanks,

> 

> Roger

> 

> 

> 

> 

> 

> javax.servlet.ServletException: Servlet execution threw an exception

> 

>         com.hyperformix.athens.filter.AthensLoginFilter.doFilter(Unknown

> Source)

> 

> root cause

> 

> java.lang.NoSuchMethodError:

> com.foo.logging.Login.aspectOf()Lcom/foo/logging/Login;

> 

>         com.foo.action.LoginAction.execute(Unknown Source)

> 

> 

> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)

> 

> 

> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)

> 

> 

> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)

> 

> 

> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)

> 

>         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)

> 

>         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

> 

>         com.foo.athens.filter.AthensLoginFilter.doFilter(Unknown Source)

> 

> 

> 

> 

> 

> 

> 

> 

> 

> @Aspect

> 

> public class Login {

> 

> 

> 

>                 static Logger log = Logger.getLogger(Login.class.getName());

> 

>                 String userName;

> 

>                 String roleName;

> 

> 

> 

>                 @Pointcut("call (* com.foo.LoginDAO.login(com.foo. Data) )

> && args(data)")

> 

>                 public void login(Data data) {}

> 

> 

> 

>                 @Before("login(data)")

> 

>                 public void loginBefore(Data data)

> 

>                 {

> 

>                                 userName = data.getUserName();

> 

>                                 roleName = data.getRoleName();

> 

>                                 BasicConfigurator.configure();

> 

>                                 log.info("User " + userName + " with role "

> + roleName + " about to login");

> 

>                 }

> 

> 

> 

> }

> 

> Roger Huang

> 

> 

> 

> _______________________________________________

> aspectj-users mailing list

> aspectj-users@xxxxxxxxxxx

> https://dev.eclipse.org/mailman/listinfo/aspectj-users

> 

> 

_______________________________________________

aspectj-users mailing list

aspectj-users@xxxxxxxxxxx

https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top