I am trying to get my aop deployed to jboss 5.1. I have written an annotation, aspect, and jboss-aop.xml. I have verified that the aspect code gets executed when a method is annotated with the JobFlow annotation through eclipse.

However, when deploying the code to jboss, the annotation has no effect.

I did the following to deploy the aop: 1. jar up the annotation and aspect into a jar file and deploy it to farm 2. deploy the jboss-aop.xml and deploy it to farm 3. set enableLoadtimeWeaving in aop.xml to true 4. copied pluggable-instrumentor.jar to the bin directory and modified run.sh to include -javaagent:pluggable-instrumentor.jar

Then I also deployed as a separate jar class that use the annotations. However, the aop is not being applied.

I can run a test outside of jboss that has the annotation and see that the aop is being applied.

Ok, I deployed docs\aspect-framework\examples\injboss example using deploy-basic-lt-war. When I bring up index.jsp I get the following the errors below indicating the SimpleInterceptor class cannot be found even though I can look at the jar inside the war and can see the class.

At any rate, it appears that jboss is trying to at least apply the aop. I have AspectManager verbose set to true. I understand that this is supposed to output info when aop is applied. When I deploy my jars that use the aop, there is absolutely no output. I don't think jboss is applying the aop in the code I am deploying (in that I see that there is output in the errors regarding joinpoints). I really appreciate your help as I have trying to resolve this issue for a couple days and cannot determine I am doing wrong.

I have a jboss-aop.xml that indicates to call the JobFlowAspect whenever the JobFlow annotation is used on a method

I have another jar that includes a classes that use the JobFlow annotation on the method.

I deployed the JobFlow.jar and jboss-aop.xml to farm, then I deploy the jars that use the annotation. When I deploy the jars that use the annotation there is no output that the aspect is being applied.

Please ignore the previous post as there was a statement that was incorrect.

Ok, I deployed docs\aspect-framework\examples\injboss example using deploy-basic-lt-war. When I bring up index.jsp I get the following the errors below indicating the SimpleInterceptor class cannot be found even though I can look at the jar inside the war and can see the class.

At any rate, it appears that jboss is trying to at least apply the aop (in that I see that there is output in the errors regarding joinpoints).

I have AspectManager verbose set to true. I understand that this is supposed to output info when aop is applied. When I deploy my jars that use the aop, there is absolutely no output. I don't think jboss is applying the aop in the code I am deploying . I really appreciate your help as I have trying to resolve this issue for a couple days and cannot determine I am doing wrong.

I have a JobFlow.jar that includes:

- JobFlow.java- JobFlowAspect.java- A few additional classes the aspect uses

I have a jboss-aop.xml that indicates to call the JobFlowAspect whenever the JobFlow annotation is used on a method

I have another jar that includes a classes that use the JobFlow annotation on the method.

I deployed the JobFlow.jar and jboss-aop.xml to farm, then I deploy the jars that use the annotation. When I deploy the jars that use the annotation there is no output that the aspect is being applied.

I resolved the classnotfound error. The aop is being applied to the injbossaop example as I see the output below.

Still trying to figure out why the aop for my classes are not being applied. Is there something different that needs to be done if the aop is being triggered via an annotation? If you have any insights, it would be most appreciated. The annotation, aspect and jboss-aop.xml is in previous replies.

"kgreenejpmc" wrote: Is there something different that needs to be done if the aop is being triggered via an annotation?

If you mean using @Aspect, @Bind etc., the classes need to be in an .aop file.

If you mean using annotations in your pointcuts, nothing special is needed. If you only remembered to add the @Retention to your @JobFlow annotation after annotating your classes with @JobFlow you should clean and recompile all the classes so the annotation gets reapplied.

Ok, after quite a bit of trial and error I finally got the aop to work. However, I have a question.

If I put my @JobFlow annotation on the onMessage method, the aop does not work. However, If I put the @JobFlow annotation on the processMessage method (which onMessage calls), the aop works. Does jboss suppress or ignore custom annotations on onMessage? If so, is there a way to enable them to work on onMessage?

If you want to intercept onMessage() only, you're probably better off creating a custom AOP domain for message driven beans (see deploy/ejb3-interceptors-aop.xml for examples of how to do this) and to use the @AspectDomain annotation on your message driven beans where you want this behaviour. This will avoid the need for weaving your classes. There should be some examples on how to do this in the ejb 3 documentation or user forum.

Regarding your question, it "should work" for onMessage(), but I am not sure how ejb3 interacts with woven classes, and since EJB3 uses AOP to configure itself, there might be some problem with aspects on EJB 3 business methods.

On discovering that the @JobFlow does not work on onMessage, I was very curious as to how annotations such as @TransactionAttribute work on onMessage (as well as other methods). These types of annotations don't seem to require loadtime weaving. In addition, you don't have to do anything special when you compile your classes that use these annotations (which leads me to believe that compile time weaving is not required either).

I did quite a bit of digging and discovered it might have to do with proxies, but I am not sure. I looked at the jboss source code, but did not see anything special in TransactionAttributeImpl.java

I am interested in developing my custom annotation and aspect such that it works like the @TransactionAttribute in that it does not require load time weaving and you don't have to compile your classes in any special way.

Am I correct in assuming that annotations such as @TransactionAttribute don't use compile time or loadtime weaving? If so, could you point me to some sources that would explain how the the code behind the annotation is triggered and executed?

On discovering that the @JobFlow does not work on onMessage, I was very curious as to how annotations such as @TransactionAttribute work on onMessage (as well as other methods). These types of annotations don't seem to require loadtime weaving. In addition, you don't have to do anything special when you compile your classes that use these annotations (which leads me to believe that compile time weaving is not required either).

I did quite a bit of digging and discovered it might have to do with proxies, but I am not sure. I looked at the jboss source code, but did not see anything special in TransactionAttributeImpl.java

I am interested in developing my custom annotation and aspect such that it works like the @TransactionAttribute in that it does not require load time weaving and you don't have to compile your classes in any special way.

Am I correct in assuming that annotations such as @TransactionAttribute don't use compile time or loadtime weaving? If so, could you point me to some sources that would explain how the the code behind the annotation is triggered and executed?

Correct, if you deploy an EJB 3 bean it constructs an EJB container without weaving. The configuration for these containers is in ejb3-interceptors-aop.xml. Calls to the ejb are done via the container and go through the stack of interceptors before hitting the ejb.

which uses pointcuts to apply the different interceptors that make up the container. e.g. the

<interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>

looks for the TransactionAttribute annotations on the different methods and applies the correct transactions.

You can either add to these domains in ejb3-interceptors-aop.xml in which case it will apply to all beans matching your pointcuts, or you can create a custom domain with more bindings and choose to apply it to a particular bean using the @AspectDomain annotation

Does it works for you? I'm trying to add some custom additional annotation on my stateless ejb which is also my webservice but it dosen't call my aspect. I'm using jboss 6 application server. Have you used your configuration on jboss 6?