Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] EJB policy enforcement: No .class file

Hi!

I have copied the EJB policy enforcement code from the "AspectJ in Action" book (page 191 - 192). The compile-time enforcement is working fine but at runtime I get a NoClassDefFoundError:

javax.ejb.TransactionRolledbackLocalException: Unexpected Error
java.lang.NoClassDefFoundError: EJBPolicyEnforcement
	at ejbs.DocumentBean.getStatusAsString(DocumentBean.java:79)

This is correct because EJBPolicyEnforcement.class is not created by Eclipse (2.1.2 with ajdt 1.1.4).

Why has the class file not been created?

I've also tried some other cflow joinpoints but I got no class file either.

Thanks for your help!

Steffen

******************************

The policy enforcement code:

public aspect EJBPolicyEnforcement {
  pointcut uiCalls() : call(* java.awt.*+.*(..));

  declare error : uiCalls() && within(EnterpriseBean+)
: "UI calls are not allowed from EJB beans.\n See EJB 2.0 specification section 24.1.2";

  before() : uiCalls() && cflow(call(* EnterpriseBean+.*(..))) {
    System.out.println("Detected call to AWT from enterprise bean");
    System.out.println("See EJB 2.0 specification section 24.1.2");
    Thread.dumpStack();
  }

  // Implementation of other programming restrictions:
  // Socket, file i/o, native library loading, keyboard input
  // thread methods access, reflection etc.
  pointcut staticMemberAccess() :
  set(static * EnterpriseBean+.*);

  declare error : staticMemberAccess()
: "EJBs are not allowed to have nonfinal static variables.\n See EJB 2.0 specification section 24.1.2";
}


Back to the top