[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Exception in thread"main"java.lang.NoClassDefFoundError

> I would hope that aspectj does NOT distinguish this:
>
>       private static final Logger logger = Logger.getLogger(My.class);
>
> from this:
>
>   private static final Logger logger;
>
>   static {
>      logger = Logger.getLogger(My.class);
>   }
>
> If it does, then we do have a problem. The two are semantically identical according to the JLS.
>
> Hermod, are you implying that aspectj does distinguish these incorrectly?

AspectJ weaving does not see the source and purely operates on
bytecode, if two constructs are compiled to the same bytecode then
they will be interpreted in the same way by the weaver.  I believe the
two constructs you specified map to the same bytecode, so AspectJ does
not see a difference.

Andy.

2008/7/2 Buck, Robert <rbuck@xxxxxxxxxxxx>:
> Hi,
>
> I would hope that aspectj does NOT distinguish this:
>
>        private static final Logger logger = Logger.getLogger(My.class);
>
> from this:
>
>    private static final Logger logger;
>
>    static {
>        logger = Logger.getLogger(My.class);
>    }
>
> If it does, then we do have a problem. The two are semantically identical according to the JLS.
>
> Hermod, are you implying that aspectj does distinguish these incorrectly?
>
> Bob
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of hermod.opstvedt@xxxxxxxxx
> Sent: Wednesday, July 02, 2008 6:59 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: RE: [aspectj-users] Exception in thread"main"java.lang.NoClassDefFoundError
>
> Hi
>
> Changing to the new weaver did the trick for us.
>
> By the way, I always do it it this way: public static final Logger LOGGER = Logger.getLogger(My.class);
>
> Hermod
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Buck, Robert
> Sent: Wednesday, July 02, 2008 12:37 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: RE: [aspectj-users] Exception in thread "main"java.lang.NoClassDefFoundError
>
> For me, this definitely happens during the weaving process during static initialization. We use log4J everywhere, and here is how we initialize a logger for a class:
>
>    private static final Logger logger;
>
>    static {
>        logger = Logger.getLogger(My.class);
>    }
>
> Here is where the weaving process throws NoClassDefFoundError with a null message.
>
> Bob
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Hermod Opstvedt
> Sent: Tuesday, July 01, 2008 4:34 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: SV:[aspectj-users]Exceptioninthread"main"java.lang.NoClassDefFoundError
>
> Hei
>
> The Aspects run fine on a WebSphere5 installation with an older Weaver. The funny thing though is that the same ting runs ok on Tomcat 6, so why this happens on WepShere 6 I am not sure. I'll upgrade the weaver tomorrow and see what happens.
>
> Hermod
>
> -----Opprinnelig melding-----
> Fra: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] På vegne av Andy Clement
> Sendt: 1. juli 2008 18:54
> Til: aspectj-users@xxxxxxxxxxx
> Emne: Re:
> [aspectj-users]Exceptioninthread"main"java.lang.NoClassDefFoundError
>
>
>> AspectJ Weaver Version DEVELOPMENT built on Wednesday Jan 23, 2008 at
>> 01:03:57 GMT
>
> Are you really using a weaver that old? I would upgrade since there are over 60 bug fixes in AspectJ1.6.1rc1.  LTW is also badly behaved in multi-classloader environment prior to 1.6.1rc1.
>
>> The errors disappear. This leads me to my conclusion that the LTW is
>> the culprit.
>
> It certainly points to weaving being the problem.  However, I can't tell if it is the way the aspects are written or incorrect weaving of the static initializer.
>
> Please raise a bug to investigate but I'll need to either see the bytecode for the initializer having a problem (obtained via dump) or the pointcuts being used.
>
> cheers,
> Andy.
>
> 2008/6/30  <hermod.opstvedt@xxxxxxxxx>:
>> Hi
>>
>> I forgot to mention that if I comment out:
>>
>>                <!--include within="org.apache.log4j..*" />
>>                <include within="org.apache.commons.logging..*" /-->
>>
>> The errors disappear. This leads me to my conclusion that the LTW is
>> the culprit.
>> I am using:
>>
>> AspectJ Weaver Version DEVELOPMENT built on Wednesday Jan 23, 2008 at
>> 01:03:57 GMT
>>
>> Hermod
>>
>> -----Original Message-----
>> From: aspectj-users-bounces@xxxxxxxxxxx
>> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
>> hermod.opstvedt@xxxxxxxxx
>> Sent: Tuesday, July 01, 2008 7:53 AM
>> To: aspectj-users@xxxxxxxxxxx
>> Subject: RE: [aspectj-users]
>> Exceptioninthread"main"java.lang.NoClassDefFoundError
>>
>> Hi
>>
>> I am suspecting that there might be a bug in AspectJ LTW and static
>> initializers. I am getting something very similar in a
>> multi-classloader (WebSphere 6.1) environment:
>>
>> Caused by: java.lang.ExceptionInInitializerError
>>        at java.lang.J9VMInternals.initialize(J9VMInternals.java:205)
>>        at java.lang.Class.newInstanceImpl(Native Method)
>>        at java.lang.Class.newInstance(Class.java:1301)
>>        at java.beans.Beans.instantiate(Beans.java:219)
>>        at java.beans.Beans.instantiate(Beans.java:63)
>>        at
>> com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.ja
>> va
>> :1305)
>>        at
>> com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.
>> java:118)
>>        at
>> com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrap
>> pe
>> r.java:1300)
>>        ... 22 more
>> Caused by: org.apache.commons.logging.LogConfigurationException:
>> java.lang.reflect.InvocationTargetException
>>        at
>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryI
>> mp
>> l.java:532)
>>        at
>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryI
>> mp
>> l.java:272)
>>        at
>> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryI
>> mp
>> l.java:246)
>>        at
>> org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
>>        at
>> org.apache.struts.action.ActionServlet.<clinit>(ActionServlet.java:228)
>>        at java.lang.J9VMInternals.initializeImpl(Native Method)
>>        at java.lang.J9VMInternals.initialize(J9VMInternals.java:187)
>>        ... 29 more
>> Caused by: java.lang.reflect.InvocationTargetException
>>        at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>        at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructo
>> rA
>> ccessorImpl.java:67)
>>        at
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCo
>> ns
>> tructorAccessorImpl.java:45)
>>        at
>> java.lang.reflect.Constructor.newInstance(Constructor.java:521)
>>        at
>> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryI
>> mp
>> l.java:525)
>>        ... 35 more
>> Caused by: java.lang.NoClassDefFoundError: org.apache.log4j.Priority
>>        at java.lang.J9VMInternals.verifyImpl(Native Method)
>>        at java.lang.J9VMInternals.verify(J9VMInternals.java:63)
>>        at java.lang.J9VMInternals.initialize(J9VMInternals.java:124)
>>        at
>> org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:63
>> )
>>
>> And from -debug
>> ...
>> [7/1/08 7:42:59:070 CEST] 00000017 SystemErr     R
>> [CompoundClassLoader@6b286b28] debug generating class
>> 'org.apache.commons.logging.impl.Log4JLogger$AjcClosure23'
>> [7/1/08 7:42:59:070 CEST] 00000017 SystemErr     R
>> [ExtClassLoader@2bc02bc0] debug weaving 'org.apache.log4j.Priority'
>> [7/1/08 7:42:59:070 CEST] 00000017 SystemErr     R
>> [ExtClassLoader@2bc02bc0] debug weaving 'org.apache.log4j.Level'
>> ..
>>
>> Priority is in the classpath as you can see, because it is loaded and
>> weaved
>>
>> Hermod
>>
>> -----Original Message-----
>> From: aspectj-users-bounces@xxxxxxxxxxx
>> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
>> Sent: Tuesday, July 01, 2008 4:37 AM
>> To: aspectj-users@xxxxxxxxxxx
>> Subject: Re: [aspectj-users] Exception
>> inthread"main"java.lang.NoClassDefFoundError
>>
>> No special setup.  The dump output should go into an folder called
>> "_ajdump" (the .class files before weaving will go into a subdir of
>> that called _before).  "_ajdump" is created relative to the current
>> directory in which the application runs.  A warning message should
>> come out if there is a problem dumping, if you don't see that then the
>> files should be somewhere...
>> Sorry if I'm a bit vague, I'm a bit rusty on LTW at the moment ;)
>>
>> Andy.
>>
>>
>> 2008/6/30 Buck, Robert <rbuck@xxxxxxxxxxxx>:
>>> Hi,
>>>
>>> <dump is not working for me at all. I am using 1.6.0.
>>>
>>> Is there some special setup necessary to get dump to work?
>>>
>>> Bob
>>>
>>> -----Original Message-----
>>> From: aspectj-users-bounces@xxxxxxxxxxx
>>> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
>>> Sent: Monday, June 30, 2008 5:53 PM
>>> To: aspectj-users@xxxxxxxxxxx
>>> Subject: Re: [aspectj-users] Exception in
>>> thread"main"java.lang.NoClassDefFoundError
>>>
>>> Hi,
>>>
>>> I've never seen a case of that before - and I've seen some pretty
>>> wierd stuff :)
>>>
>>>> Exception in thread "main" java.lang.NoClassDefFoundError
>>>>        at $AllProbeAspect.aspectOf(Unknown Source)
>>>
>>> You could turn on weaveinfo messages and see if anywhere unexpected
>>> is
>>
>>> getting woven by your aspects, I think that is <weaver
>>> options="-showWeaveInfo"
>>>
>>> Or it would be interesting to turn on dump diagnostics for the weaver
>>> pre- and post- weave and then see how that method had been affected
>>> during the weave and is it bad code.  (It seems like the code is OK
>>> because there is no verifyerror.)
>>>
>>> To turn on that debugging, add this option to weaver options:
>>>
>>>  <dump within="com.verisign.common.properties..*"
>>> beforeandafter="true"/>
>>>
>>> navigating from the PropertyManager.getInstance() method using a
>>> decompiler or javap on the woven code and seeing where it leads.
>>>
>>> My suspicion right now is that something is being woven that you
>>> weren't expecting and it is having a nasty side effect.
>>>
>>> If you want me to take a look at the bytecode, I'm happy to - use my
>>> regular gmail ID if you don't want to share it with the list.
>>>
>>> cheers,
>>> Andy.
>>>
>>>
>>> 2008/6/30 Buck, Robert <rbuck@xxxxxxxxxxxx>:
>>>> Hi Andy,
>>>>
>>>> Okay, so I reverted back to double-dots. The doc was not very clear,
>>>> which is why I tried single-dots. But still, I get the same error:
>>>>
>>>> Exception in thread "main" java.lang.NoClassDefFoundError
>>>>        at $AllProbeAspect.aspectOf(Unknown Source)
>>>>        at
>>>> com.verisign.common.properties.PropertyManager.getInstance(PropertyM
>>>> a
>>>> n
>>>> ag
>>>> er.java:81)
>>>>        at com.verisign.jtaps.test.Test.calc(Test.java:19)
>>>>        at com.verisign.jtaps.test.Test.main(Test.java:29)
>>>>
>>>> Notice that there is no class name specified; when I trap all
>>>> exceptions in the debugger, what I see is a null error message, and
>>>> the causation member self-references the lexically enclosing
>>>> exception
>>>
>>>> instance, as if somewhere someone did something evil like:
>>>>
>>>>  NoClassDefFoundError error = new NoClassDefFoundError();
>>>> error.initCause(error);  throw error;
>>>>
>>>> The information I Google'd did not turn up any hints that worked.
>>>>
>>>> What sort of approach might I use to dianose and resolve this issue?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Bob
>>>>
>>>> -----Original Message-----
>>>> From: aspectj-users-bounces@xxxxxxxxxxx
>>>> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
>>>> Sent: Monday, June 30, 2008 5:14 PM
>>>> To: aspectj-users@xxxxxxxxxxx
>>>> Subject: Re: [aspectj-users] Exception in thread
>>>> "main"java.lang.NoClassDefFoundError
>>>>
>>>> In AspectJ syntax, the expression
>>>>
>>>> pkg.*
>>>>
>>>> means any type in package 'pkg'.  If your type is in pkg.subpkg then
>>>> it will not match that expression.  Two dots are needed to include
>>>> types in the package or any sub-package.
>>>>
>>>> pkg..*
>>>>
>>>> Going by the aop.xml in your previous email, you are using
>>>> org.apache.log4j.*  and that doesn't match
>>>> org.apache.log4j.spi.RootLogger, so it is not excluded from the
>>>> weaving process.
>>>>
>>>> The doc is here:
>>>> http://www.eclipse.org/aspectj/doc/released/devguide/ltw-configurati
>>>> o
>>>> n
>>>> .h
>>>> tml
>>>> but i'll say that if you aren't familiar with the double dot
>>>> notation,
>>>
>>>> it isn't explicitly indicated there as what you need to use, and the
>>>> example on that page is a bit unclear.  we could do with improving
>>>> that doc.
>>>>
>>>> cheers,
>>>> Andy.
>>>>
>>>> 2008/6/30 Buck, Robert <rbuck@xxxxxxxxxxxx>:
>>>>> Hello,
>>>>>
>>>>> I have been grappling with an issue for a couple weeks now. No
>>>>> information in the documentation, on the web via google, seems to
>>>>> point me in the right direction. I looked through the aspectj
>>>>> database, and nothing there to help either.
>>>>>
>>>>> I put together a simple hello world application to diagnose an
>>>>> issue
>>
>>>>> I
>>>>
>>>>> see when using aspectj in a larger scale application. Here is my
>>>> question...
>>>>>
>>>>> Why, when I specifically tell aspectj not to weave log4j, does it
>>>>> try
>>>> to?
>>>>> (assuming the stack trace below hints this, because the standalone
>>>>> application works properly).
>>>>>
>>>>> Or, is there a bug in the aspectj agent that would cause this?
>>>>>
>>>>> Or, is there a bug in aspectj with respect to static initializer
>>>> blocks?
>>>>>
>>>>> Exception in thread "main" java.lang.NoClassDefFoundError  at
>>>>> org.apache.log4j.spi.RootLogger.<init>(RootLogger.java:46)
>>>>>  at org.apache.log4j.LogManager.<clinit>(LogManager.java:80)
>>>>>  at org.apache.log4j.Logger.getLogger(Logger.java:118)
>>>>>  at
>>>>> com.verisign.common.properties.PropertyManager.<clinit>(PropertyMan
>>>>> a
>>>>> g
>>>>> e
>>>>> r.java:47)  at com.verisign.jtaps.test.Test.calc(Test.java:19)
>>>>>  at com.verisign.jtaps.test.Test.main(Test.java:29)
>>>>> Thanks
>>>>>
>>>>> Bob
>>>>> _______________________________________________
>>>>> 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
>>>> _______________________________________________
>>>> 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
>>> _______________________________________________
>>> 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
>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>> *
>> * *
>>
>> This email with attachments is solely for the use of the individual or
>> entity to whom it is addressed. Please also be aware that the DnB NOR
>> Group cannot accept any payment orders or other legally binding
>> correspondence with customers as a part of an email.
>>
>> This email message has been virus checked by the anti virus programs
>> used in the DnB NOR Group.
>>
>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>> *
>> * *
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>> * * *
>>
>> This email with attachments is solely for the use of the individual or
>> entity to whom it is addressed. Please also be aware that the DnB NOR
>> Group cannot accept any payment orders or other legally binding
>> correspondence with customers as a part of an email.
>>
>> This email message has been virus checked by the anti virus programs
>> used in the DnB NOR Group.
>>
>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>> * * *
>>
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>
> This email with attachments is solely for the use of the individual or entity to whom it is addressed. Please also be aware that the DnB NOR Group cannot accept any payment orders or other legally binding correspondence with customers as a part of an email.
>
> This email message has been virus checked by the anti virus programs used in the DnB NOR Group.
>
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>
> _______________________________________________
> 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
>