Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Issues deploying aspects

Hi James,

I have a couple of comments below. First off, though, I don't think you want to use a call pointcut for capturing EJB methods because the call to the session bean will be made by the container (and probably reflectively). I would suggest using an execution pointcut because you do control the code for executing the session beans (i.e., it's easy to weave into that).

You could use this version:
   pointcut executingMethod() : this(SessionBean) && execution(public * *(..)); 

Now to your questions:
>1) When I have specified SessionBean, why does aspectj touch JobTranslationBean which is an >EntityBean? 
AspectJ 1.1.1 did not include an optimization to restrict weaves into calls based on the dynamic type of the target. However, AspectJ 1.2rc2 does have an optimization that restricts where join points get woven in this way. If you didn't want to use AspectJ 1.1.1 you probably would want to use this alternative:
   pointcut executingMethod() : execution(public * SessionBean+.*(..)); 
It probably means the same thing for your code (unless you have methods in a base class of your session beans that you also want to secure...)

>2) Since it has touched my EntityBean, why has it put an additional field on it? 
This field holds information about the call join point because you access thisJoinPoint in your advice.

3) JobTranslationBean is in a seperate package, I only want my aspect to effect the classes in the package it itself is in. How can I do that?

   pointcut executingMethod() : 
       this(SessionBean) && execution(public * *(..)) && within(com.example.mypackage..*); 

------------Original Message------------
From: James Cook <James.Cook@xxxxxxxxxxxxxxx>
To: "'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>
Date: Mon, May-24-2004 9:21 AM
Subject: [aspectj-users] Issues deploying aspects
Excuse my newbie questions, but I am having some problems getting aspects to work correctly. 
When I try the following aspect on my code: 
import javax.ejb.*; 
public aspect Security { 
    pointcut callingMethod() : target(SessionBean) && call(public * *(..)); 
    before(): callingMethod() { 
        System.out.println("Entering " + thisJoinPoint); 
        Object[] tmp = thisJoinPoint.getArgs(); 
        for (int i = 0; i < tmp.length; i++) { 
            SecurityChecker.check(tmp[i], SecurityChecker.TEXT); 
        } 
    } 
} 
I get the following error when deploying: 
Unable to deploy EJB: erm-ejb.jar from erm-ejb.jar: 
In EJB JobTranslationBean, the primary key field named ajc$tjp_0 is not a CMP managed field. 
        at weblogic.ejb20.compliance.EJBComplianceChecker.check(EJBComplianceChecker.java:268) 
        at weblogic.ejb20.compliance.EJBComplianceChecker.checkDeploymentInfo(EJBComplianceChecker.java:232) 
        at weblogic.ejb20.ejbc.EJBCompiler.complianceCheckJar(EJBCompiler.java:810) 
        at weblogic.ejb20.ejbc.EJBCompiler.checkCompliance(EJBCompiler.java:766) 
        ...etc 


Now this presents several questions: 

Thanks in advance 
James 
Setup: 
Java 1.4.2 
aspectj-1.1.1 
Weblogic 8.1 


Back to the top