Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » NoClassDefFoundError with Aspectj 1.2 (upd) on Eclipse 2.1.3
NoClassDefFoundError with Aspectj 1.2 (upd) on Eclipse 2.1.3 [message #39680] Mon, 02 August 2004 06:36 Go to next message
Eclipse UserFriend
Originally posted by: christian.eugster.bluewin.ch

Hello

I am using Eclipse 2.1.3, have ajdt 1.4 installed and updated for Aspectj
1.2. Because I am new to aspect-oriented Programming, I tried to implement
first a logging aspect as I learned by "AspectJ in action" (see the source
below). I can ompile the whole code without problems, but running the
example I get always an NoClassDefFoundError. This Error occures at the
first place, where i use one of my core classes named Path, that has some
static String constants containing pathnames to the system. Without aspectj
the project runs problemless.

I searched the web, found an entry in the bugzilla tool for eclipse
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=44587) but that points to
ajdt 1.4 without update. Has anybody any idea how I could solve that
problem? Thank you in advance!

Christian

/*

* Created on 21.07.2004

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

package ch.eugster.pos;

import ch.eugster.pos.client.event.ExceptionThrownDelegate;

import ch.eugster.pos.client.event.ExceptionThrownEvent;

import ch.eugster.pos.util.Path;

import java.io.IOException;

import java.lang.SecurityException;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.logging.FileHandler;

import java.util.logging.Level;

import java.util.logging.Logger;

import java.util.logging.SimpleFormatter;

import org.aspectj.lang.Signature;



/**

* @author ceugster

*

* To change the template for this generated type comment go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

public aspect LoggingAspect {


private Logger _logger = Logger.getLogger("logging");

private Level level = Level.SEVERE;


LoggingAspect() {

_logger.setLevel(level);


try {

FileHandler fh = new FileHandler(Path.logDir.concat(Path.FILE_LOG), true);

fh.setFormatter(new SimpleFormatter());

}

catch (IOException e) {

}

catch (SecurityException e) {

}

catch (ExceptionInInitializerError e) {

}

}


pointcut traceMethods()

: execution(* *(..)) && !within(LoggingAspect);


before() : traceMethods() {

if (_logger.isLoggable(Level.INFO)) {

Signature sig = thisJoinPointStaticPart.getSignature();

_logger.logp(Level.INFO,

sig.getDeclaringType().getName(),

sig.getName(),

"Entering: " + sig.getDeclaringType().getName() + "." + sig.getName());

}

}


after() : traceMethods() {

if (_logger.isLoggable(Level.INFO)) {

Signature sig = thisJoinPointStaticPart.getSignature();

_logger.logp(Level.INFO,

sig.getDeclaringType().getName(),

sig.getName(),

"Leaving: " + sig.getDeclaringType().getName() + "." + sig.getName());

}

}

pointcut exceptionLogMethods()

: execution(* *(..)) && !within(LoggingAspect);


after() throwing(Throwable ex) : exceptionLogMethods() {

if (_logger.isLoggable(Level.WARNING)) {

Signature sig = thisJoinPointStaticPart.getSignature();

_logger.logp(Level.WARNING,

sig.getDeclaringType().getName(),

sig.getName(),

"Exception thrown: " +

ex.getLocalizedMessage());

}

DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT,
SimpleDateFormat.SHORT);

ExceptionThrownDelegate.fireExceptionThrownEvent(new
ExceptionThrownEvent(df.format(new Date()) + ": Exception thrown - " +
ex.getLocalizedMessage() + "\n"));

}


}
Re: NoClassDefFoundError with Aspectj 1.2 (upd) on Eclipse 2.1.3 [message #39712 is a reply to message #39680] Mon, 02 August 2004 13:55 Go to previous message
Eclipse UserFriend
Originally posted by: mchapman.uk.ibm.com

On Mon, 02 Aug 2004 08:36:21 +0200, Christian Eugster wrote:
> I am using Eclipse 2.1.3, have ajdt 1.4 installed and updated for Aspectj
> 1.2. Because I am new to aspect-oriented Programming, I tried to
> implement first a logging aspect as I learned by "AspectJ in action" (see
> the source below). I can ompile the whole code without problems, but
> running the example I get always an NoClassDefFoundError. This Error
> occures at the first place, where i use one of my core classes named Path,
> that has some static String constants containing pathnames to the system.
> Without aspectj the project runs problemless.
>
> I searched the web, found an entry in the bugzilla tool for eclipse
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=44587) but that points to
> ajdt 1.4 without update. Has anybody any idea how I could solve that
> problem? Thank you in advance!

I'm not certain what is happening here, but the initializer might be
throwing an exception, which is then resulting in the
NoClassDefFoundError. I suggest you try adding a "catch (Throwable t)" to
the catch block around the call to new FileHandler, then do
"t.printStackTrace();" there, to see if this is the case.

Regards,

Matt.
Re: NoClassDefFoundError with Aspectj 1.2 (upd) on Eclipse 2.1.3 [message #582479 is a reply to message #39680] Mon, 02 August 2004 13:55 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
Messages: 429
Registered: July 2009
Senior Member
On Mon, 02 Aug 2004 08:36:21 +0200, Christian Eugster wrote:
> I am using Eclipse 2.1.3, have ajdt 1.4 installed and updated for Aspectj
> 1.2. Because I am new to aspect-oriented Programming, I tried to
> implement first a logging aspect as I learned by "AspectJ in action" (see
> the source below). I can ompile the whole code without problems, but
> running the example I get always an NoClassDefFoundError. This Error
> occures at the first place, where i use one of my core classes named Path,
> that has some static String constants containing pathnames to the system.
> Without aspectj the project runs problemless.
>
> I searched the web, found an entry in the bugzilla tool for eclipse
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=44587) but that points to
> ajdt 1.4 without update. Has anybody any idea how I could solve that
> problem? Thank you in advance!

I'm not certain what is happening here, but the initializer might be
throwing an exception, which is then resulting in the
NoClassDefFoundError. I suggest you try adding a "catch (Throwable t)" to
the catch block around the call to new FileHandler, then do
"t.printStackTrace();" there, to see if this is the case.

Regards,

Matt.
Previous Topic:NoClassDefFoundError with Aspectj 1.2 (upd) on Eclipse 2.1.3
Next Topic:AJDT version 1.1.11 works with AspectJ version 1.2 or 1.1.1 ?
Goto Forum:
  


Current Time: Tue Apr 16 07:59:47 GMT 2024

Powered by FUDForum. Page generated in 0.13844 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top