Quantcast

another 'noaspectboundexception: exception while initializing ....'. plz help

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

another 'noaspectboundexception: exception while initializing ....'. plz help

Ashank
Hello All!

I am using LTW with AJ 1.6.9. I'm trying to instrument any interesting POJO class in my web app and I wrote this pointcut for this (partial aspect enclosed)
<snip>
package test;

public aspect POJOAspect extends GenericAspect{
        public pointcut POJOPC() :
                !within(test.*) &&
                !execution(public new(..)) &&
        !(execution(* java..*(..)) || execution(java..new(..))) &&
        !(execution(native * *(..)) || execution(native new(..))) &&
                execution(public * *(..));
</snip>

GenericAspect is just an abstract dummy aspect that I use to do stuff for my web app. All my aspects extend it. Some pointcuts in my aspect may be redundant but I'm just pasting it here as they are in my code.

When I ran my web server, I get the following exception

org.aspectj.lang.NoAspectBoundException: Exception while initializing test_aspects_POJOAspect: org.aspectj.lang.NoAspectBoundException: test_aspects_POJOAspect
        at test.aspects.POJOAspect.aspectOf(POJOAspect.aj:1)
        at org.apache.ajp.tomcat4.Ajp13Connector.setContainer(Ajp13Connector.java:403)
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:245)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.util.xml.AddChild.end(XmlMapper.java:811)
        at org.apache.catalina.util.xml.XmlMapper.matchEnd(XmlMapper.java:419)
        at org.apache.catalina.util.xml.XmlMapper.endElement(XmlMapper.java:119)
        at org.xml.sax.helpers.XMLReaderAdapter.endElement(XMLReaderAdapter.java:347)
        at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
        at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
        at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1809)
        at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1182)
        <......snipped........./>

Caused by: org.aspectj.lang.NoAspectBoundException: test_aspects_POJOAspect
        at test.aspects.POJOAspect.aspectOf(POJOAspect.aj:1)
        at test.StartServer.startThread(StartServer.java:37)
        at test.aspects.GenericAspect.<init>(GenericAspect.aj:15)
        at test.aspects.POJOAspect.<init>(POJOAspect.aj:11)
        at test.aspects.POJOAspect.ajc$postClinit(POJOAspect.aj:1)
        at test.aspects.POJOAspect.<clinit>(POJOAspect.aj:11)
        at org.apache.ajp.tomcat4.Ajp13Connector.setPort(Ajp13Connector.java:574)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.util.xml.SetProperties.setProperty(XmlMapper.java:703)
        at org.apache.catalina.util.xml.SetProperties.start(XmlMapper.java:650)
        at org.apache.catalina.util.xml.XmlMapper.matchStart(XmlMapper.java:412)
        at org.apache.catalina.util.xml.XmlMapper.startElement(XmlMapper.java:91)
        at org.xml.sax.helpers.XMLReaderAdapter.startElement(XMLReaderAdapter.java:329)
        at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
        at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284)
        at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
       <....snipped...../>

I checked out a bunch of posts about noaspectboundexception and about cyclic advising but don't know how I am facing that issue (if at all) when I am not advising any class in the test package (where my POJOAspect resides).
Please help!!!
Thank you very much


-Arvind
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: another 'noaspectboundexception: exception while initializing ....'. plz help

Ashank
Oh...Here are my trivial advices if they may contribute to my exception.

        before():POJOPC() {
                String className = thisJoinPointStaticPart.getSignature().getDeclaringTypeName();
                String methName = thisJoinPointStaticPart.getSignature().getName();
                System.out.println("before:className " + className);
                System.out.println("before: methName " + methName);
        }

        after():POJOPC() {
                String className = thisJoinPointStaticPart.getSignature().getDeclaringTypeName();
                String methName = thisJoinPointStaticPart.getSignature().getName();
                System.out.println("after:className " + className);
                System.out.println("after: methName " + methName);
        }
Sorry. Forgot to include them in earlier post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: another 'noaspectboundexception: exception while initializing ....'. plz help

Andy Clement
In reply to this post by Ashank
Hi,

Your snippet of code says POJOAspect is in package test.  But your
stack trace says it is in package test.aspects.  Your !within(test.*)
will not exclude the aspect if it is in test.aspects, since you only
include one '.'.

Caused by: org.aspectj.lang.NoAspectBoundException: test_aspects_POJOAspect
       at test.aspects.POJOAspect.aspectOf(POJOAspect.aj:1)
       at test.StartServer.startThread(StartServer.java:37)
       at test.aspects.GenericAspect.<init>(GenericAspect.aj:15)
       at test.aspects.POJOAspect.<init>(POJOAspect.aj:11)
       at test.aspects.POJOAspect.ajc$postClinit(POJOAspect.aj:1)
       at test.aspects.POJOAspect.<clinit>(POJOAspect.aj:11)

This piece of the stack suggests that an attempt is being made to call
something that is advised whilst the aspect instance is being
constructed.  Your startThread() code is trying to access the aspect
before it has finished being constructed.  You could try reorganizing
that logic (don't call startThread from the genericaspect constructor)
or you could try a cflow to avoid the advice call in startThread if in
the cflow of the aspects constructor.

Andy

On 17 August 2010 07:54, Ashank <[hidden email]> wrote:

>
> Hello All!
>
> I am using LTW with AJ 1.6.9. I'm trying to instrument any interesting POJO
> class in my web app and I wrote this pointcut for this (partial aspect
> enclosed)
> <snip>
> package test;
>
> public aspect POJOAspect extends GenericAspect{
>        public pointcut POJOPC() :
>                !within(test.*) &&
>                !execution(public new(..)) &&
>        !(execution(* java..*(..)) || execution(java..new(..))) &&
>        !(execution(native * *(..)) || execution(native new(..))) &&
>                execution(public * *(..));
> </snip>
>
> GenericAspect is just an abstract dummy aspect that I use to do stuff for my
> web app. All my aspects extend it. Some pointcuts in my aspect may be
> redundant but I'm just pasting it here as they are in my code.
>
> When I ran my web server, I get the following exception
>
> org.aspectj.lang.NoAspectBoundException: Exception while initializing
> test_aspects_POJOAspect: org.aspectj.lang.NoAspectBoundException:
> test_aspects_POJOAspect
>        at test.aspects.POJOAspect.aspectOf(POJOAspect.aj:1)
>        at
> org.apache.ajp.tomcat4.Ajp13Connector.setContainer(Ajp13Connector.java:403)
>        at
> org.apache.catalina.core.StandardService.addConnector(StandardService.java:245)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at org.apache.catalina.util.xml.AddChild.end(XmlMapper.java:811)
>        at
> org.apache.catalina.util.xml.XmlMapper.matchEnd(XmlMapper.java:419)
>        at
> org.apache.catalina.util.xml.XmlMapper.endElement(XmlMapper.java:119)
>        at
> org.xml.sax.helpers.XMLReaderAdapter.endElement(XMLReaderAdapter.java:347)
>        at
> org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
>        at
> org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
>        at
> org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1809)
>        at
> org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1182)
>        <......snipped........./>
>
> Caused by: org.aspectj.lang.NoAspectBoundException: test_aspects_POJOAspect
>        at test.aspects.POJOAspect.aspectOf(POJOAspect.aj:1)
>        at test.StartServer.startThread(StartServer.java:37)
>        at test.aspects.GenericAspect.<init>(GenericAspect.aj:15)
>        at test.aspects.POJOAspect.<init>(POJOAspect.aj:11)
>        at test.aspects.POJOAspect.ajc$postClinit(POJOAspect.aj:1)
>        at test.aspects.POJOAspect.<clinit>(POJOAspect.aj:11)
>        at
> org.apache.ajp.tomcat4.Ajp13Connector.setPort(Ajp13Connector.java:574)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at
> org.apache.catalina.util.xml.SetProperties.setProperty(XmlMapper.java:703)
>        at
> org.apache.catalina.util.xml.SetProperties.start(XmlMapper.java:650)
>        at
> org.apache.catalina.util.xml.XmlMapper.matchStart(XmlMapper.java:412)
>        at
> org.apache.catalina.util.xml.XmlMapper.startElement(XmlMapper.java:91)
>        at
> org.xml.sax.helpers.XMLReaderAdapter.startElement(XMLReaderAdapter.java:329)
>        at
> org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
>        at
> org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284)
>        at
> org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
>       <....snipped...../>
>
> I checked out a bunch of posts about noaspectboundexception and about cyclic
> advising but don't know how I am facing that issue (if at all) when I am not
> advising any class in the test package (where my POJOAspect resides).
> Please help!!!
> Thank you very much
>
>
> -Arvind
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/another-noaspectboundexception-exception-while-initializing-plz-help-tp2328492p2328492.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> [hidden email]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: another 'noaspectboundexception: exception while initializing ....'. plz help

Ashank
Thanks Andy, for the tips! Realized whats wrong.

The method I have in the constructor of the parent aspect calls a bunch of other advised methods which get invoked even before the parent aspect constructor (and hence the constructor of my aspect) has had a chance to finish. Hence the exception. I ended up skipping the package with my aspects and the package containing the method called from the parent aspect constructor.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: another 'noaspectboundexception: exception while initializing ....'. plz help

Ashank
Filtering using cflow is a more optimal idea although I don't have a need to advise my own package
Loading...