|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
FW: NoSuchMethodError: aspectOf()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@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: 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@...>: > 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@... > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
RE: 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----- 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@...>: > 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 >
https://dev.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ aspectj-users mailing list https://dev.eclipse.org/mailman/listinfo/aspectj-users _______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: FW: NoSuchMethodError: aspectOf()Hi Roger,
There are three paths to think about with AspectJ: classpath: for resolving references found in any of the code the compiler/weaver are processing. This path is not searched for aspects, and the contents of it are not woven and not copied to the output folder. inpath: input .class files for weaving. Contents of this path *are* woven and *are* copied to the output folder, it is also searched for aspects. aspectpath: input aspect .class files for weaving. Contents of this path are not woven and are not copied to the output folder, but it is searched for aspects. Your annotation style aspect is compiled by javac and then passed in via aspectpath. Unfortunately as I have written above, the contents of aspect path are not woven - so your aspect is never 'finished off'. You have a few options: 1) compile the aspect with iajc rather than javac. 2) after compiling with javac, add a step to pass it through iajc to finish it off. 3) pass it on inpath to your existing iajc call. Each has pros/cons. (1) you may have written the aspect using annotations in the first place to avoid using iajc initially. (2) adds extra compile step to your process. (3) the woven aspect will go into the output folder. So the aspect class files will be 'mixed up' with your woven application. cheers, Andy 2009/10/31 Roger Huang <rhuang@...>: > 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@... > [mailto:aspectj-users-bounces@...] On Behalf Of Andy Clement > Sent: Friday, October 30, 2009 5:32 PM > To: aspectj-users@... > 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@...>: > >> 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@... > >> https://dev.eclipse.org/mailman/listinfo/aspectj-users > >> > >> > > _______________________________________________ > > aspectj-users mailing list > > aspectj-users@... > > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ > aspectj-users mailing list > aspectj-users@... > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
RE: FW: NoSuchMethodError: aspectOf()Hi Andy,
Thank you for the detailed explanation. My aspect works now. Thanks, Roger -----Original Message----- From: aspectj-users-bounces@... [mailto:aspectj-users-bounces@...] On Behalf Of Andy Clement Sent: Sunday, November 01, 2009 7:49 PM To: aspectj-users@... Subject: Re: [aspectj-users] FW: NoSuchMethodError: aspectOf() Hi Roger, There are three paths to think about with AspectJ: classpath: for resolving references found in any of the code the compiler/weaver are processing. This path is not searched for aspects, and the contents of it are not woven and not copied to the output folder. inpath: input .class files for weaving. Contents of this path *are* woven and *are* copied to the output folder, it is also searched for aspects. aspectpath: input aspect .class files for weaving. Contents of this path are not woven and are not copied to the output folder, but it is searched for aspects. Your annotation style aspect is compiled by javac and then passed in via aspectpath. Unfortunately as I have written above, the contents of aspect path are not woven - so your aspect is never 'finished off'. You have a few options: 1) compile the aspect with iajc rather than javac. 2) after compiling with javac, add a step to pass it through iajc to finish it off. 3) pass it on inpath to your existing iajc call. Each has pros/cons. (1) you may have written the aspect using annotations in the first place to avoid using iajc initially. (2) adds extra compile step to your process. (3) the woven aspect will go into the output folder. So the aspect class files will be 'mixed up' with your woven application. cheers, Andy 2009/10/31 Roger Huang <rhuang@...>: > 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\LoginAct > ion.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@... > [mailto:aspectj-users-bounces@...] On Behalf Of Andy Clement > Sent: Friday, October 30, 2009 5:32 PM > To: aspectj-users@... > 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@...>: > >> 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(Reques >> tProcessor.java:421) > >> > >> > >> >> org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja >> va:226) > >> > >> > >> org.apache.struts.action.ActionServlet.process(ActionServlet.java:116 >> 4) > >> > >> > >> 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@... > >> https://dev.eclipse.org/mailman/listinfo/aspectj-users > >> > >> > > _______________________________________________ > > aspectj-users mailing list > > aspectj-users@... > > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ > aspectj-users mailing list > aspectj-users@... > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
| Free embeddable forum powered by Nabble | Forum Help |