Bug 82130 - newsgroup report: BCE Exception:illegal change to pointcut declaration
Summary: newsgroup report: BCE Exception:illegal change to pointcut declaration
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-04 08:25 EST by Andrew Clement CLA
Modified: 2005-10-21 03:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2005-01-04 08:25:35 EST
Following is from a post to the newsgroup.  Although he has resolved the
situation, he shouldnt be getting a BCException.

---


Never mind.  I was using the "setSessionContext" as the pointcut name.    
This name is used inside the advice as well.   Sorry for the confusion

Thanks


Sekar Gopinathan wrote:

> Hi,
> I am using aspects to do make my code independant of the J2EE container 
> without going into Spring framework.    In order to accomplish this I have 
> a stateless session EJB that merely acts as wrapper providing 
> transactional capabilities.   Inside the EJB, I instantialte a 
> BusinessService class and set the BusinessSessionContext(contains info 
> such as the current user).   For every call to the ejb I set the context 
> and then call the business methods in the service object.    I am planning 
> to refactor the application such that aspect sets the "business session 
> context" into the service object before calling the business methods of 
> the service.   This will let the service know the currently logged on user 
> and hence can use this info during audit.(Which again is an aspect).    So 
> I wrote two aspects 
> 1. for setting the session context
> 2. for doing the audit after each service is completed
> The aspects look like
> 1.
> public aspect Context {

> 		 pointcut setSessionContext(AbstractBusinessServiceEjbBean 
> businessServiceEjb):
> 		 		 call(* AbstractBusinessService.execute(..)) && 
> target(businessServiceEjb) ;

> 		 before(AbstractBusinessServiceEjbBean businessServiceEjb) throws 
> InvalidCTXParamException :setSessionContext(businessServiceEjb){
> 		     SessionContext sessionContext=new SessionContext();

> 
sessionContext.storeContext(Constants.SESSION_CONTEXT_USER_KEY,businessServiceEjb.getUserId());
> 		     businessServiceEjb.getService().setSessionContext(sessionContext);

> 		 }

> }
> 2.
> public aspect DoAudit {

> 		 		 pointcut writingAudit() :
> 		 		 		 call(* AuditService.execute(..));

> 		 		 declare warning : writingAudit() && !within(DoAudit)
> 		 		 : "Only DoAudit policy can call AuditService";

> 		 		 pointcut doAudit(AbstractBusinessService businessService) :
> 		 		 		 execution(* execute(..)) && this(businessService);

> 		 		 after(AbstractBusinessService businessService) throws SystemException  : 
> doAudit(businessService) {
> 		 		 		 AuditService auditStep=null;
> 		 		 		 auditStep=(AuditService)new 
> BusinessFactory().create(AuditService.class.getName());
> 
		 		 		
((AbstractBusinessService)auditStep).setSessionContext(businessService.getSessionContext());
> 		 		 		 auditStep.execute((BusinessStep)businessService);
> 		 		 }

> }
> When I clean the project and rebuild the project, I get a BCEException 
> right around the line 
> 
"((AbstractBusinessService)auditStep).setSessionContext(businessService.getSessionContext());"


> Exception reads:  
> BCE Exception:illegal change to pointcut declaration:
> setSessionContext(BindingTypePattern(com.xxx.backoffice.common.sb.Abs...(not 
> clear after this)

> Note: I had my "incremental compile" turned on.

> I am kind of stuck.  Any help here appreciated.

> Thanks
> SG
Comment 1 Andrew Clement CLA 2005-10-20 12:25:57 EDT
related to something I am working on...
Comment 2 Andrew Clement CLA 2005-10-21 03:04:57 EDT
Under another bug I have just removed the unhelpful exception 'illegal change to
pointcut declaration'.  There were situations where it was incorrectly coming
out and there was a better message hiding behind it that users wouldn't
typically see.

I'm closing this as resolved too :)