11 Replies Latest reply on Mar 23, 2006 8:00 AM by kabirkhan

    DynamicAOP not working with Examples

    tpedone

      I'm using the injboss example to try out DynamicAOP. I startup JBoss with the jboss-aop.xml file in the /server/all/deploy dir. I then drop in the aopexample.ear that was built from the example. The ear deploys and I can see the interceptors print to the console like they are supposed to. I remove the jboss-aop.xml file and the interceptors no longer print (so far, so good). When I drop the jboss-aop.xml file back into the deploy dir I get the following stack dump:

      2006-03-08 16:28:19,113 INFO [STDOUT] [error] java.lang.RuntimeException: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.injbossaop.lib.SimpleInterceptor file:/C:/jboss-4.0.3SP1/server/all/tmp/deploy/tmp4259jboss-aop.xml
      2006-03-08 16:28:19,113 INFO [STDOUT] java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.injbossaop.lib.SimpleInterceptor
      2006-03-08 16:28:19,113 INFO [STDOUT] at org.jboss.aop.AspectXmlLoader.deployXML(AspectXmlLoader.java:832)
      2006-03-08 16:28:19,113 INFO [STDOUT] at org.jboss.aop.AspectXmlLoader.deploy(AspectXmlLoader.java:1139)
      2006-03-08 16:28:19,113 INFO [STDOUT] at org.jboss.aop.AspectXmlLoader.deployXML(AspectXmlLoader.java:1159)
      2006-03-08 16:28:19,113 INFO [STDOUT] at org.jboss.aop.deployment.AspectDeployer.create(AspectDeployer.java:163)
      2006-03-08 16:28:19,113 INFO [STDOUT] at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)
      2006-03-08 16:28:19,113 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)
      


      SimpleInterceptor is in the ear file, if it weren't the original deployment would not have worked.

      I made sure to build the ear that did not include the jboss-aop.xml file in it as well.

      I'm using JBoss 4.0.3SP1 and AOP 1.3.5. Any ideas?

      Thanks,

      Tim

        • 1. Re: DynamicAOP not working with Examples
          kabirkhan

          That is bizarre. I just tried it here, and it worked as expected. Did you change the example in any way?

          • 2. Re: DynamicAOP not working with Examples
            tpedone

            No I didn't. I just built it. One thing that may be different is that I installed my copy of JBoss using the jar installer since we're using EJB3. I'll try it using the standard JBoss zip distribution and post the results here.

            Tim

            • 3. Re: DynamicAOP not working with Examples
              tpedone

              OK I tried this on a fresh copy of JBoss 4.0.3SP1 that was simply unzipped to a directory and it worked.

              I then used the jar installer to install JBoss using the "all" configuration and got the same error as I reported in my original post.

              In both cases I used the same procedure to update AOP (removed the old AOP deploy dir, copy the new one, put the pluggable-instrumentor.jar in the bin dir and added -javaagent:pluggable-instrumentor.jar to the JAVA_OPTS in run.bat.

              BTW, I when I installed using the jar installer, I did it twice, once with the "Enable deployment isolation/call by value" checked and once with in unchecked. Both failed.

              Tim

              • 4. Re: DynamicAOP not working with Examples
                kabirkhan

                I've created a JIRA issue
                http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929100#3929100

                Thanks for investigating.

                You're able to use it with the unzipped version right?

                • 5. Re: DynamicAOP not working with Examples
                  tpedone

                  The unzipped version worked. We have been using the installed version. I'll have to try installing EJB3 manually into the unzipped version and see if that works. If so, then we can proceed using that for now.

                  • 6. Re: DynamicAOP not working with Examples
                    tpedone

                    The example worked when I ran it in the unzipped JBoss distribution with a manually installed EJB3 RC3 installation. So, it appears to only fail when running in an instance installed with the jar installer installing the "all" configuration.

                    • 7. Re: DynamicAOP not working with Examples
                      kabirkhan

                      The installer seems to incorrectly set Isolated and CallByValue to true regardless of what you select, so I got the same errors as you.

                      Changing these values to false in ear-deployer.xml fixes the problem.

                      • 8. Re: DynamicAOP not working with Examples
                        tpedone

                        After trying to get my own aspects to work, I went back to example and noticed that not all the interceptors are working when I re-deploy the jboss-aop.xml. In particular, ExampleSessionBean.getValue() and EarExampleServlet.service() are not intercepted even though they were when I first deployed the aopexample.ear. I'm having a similar problem with my app. After removing, then re-deploying my aop.xml file, my interceptors stop working.

                        It's as if the interceptors only work only on instances that were constructed since re-deploying the aop.xml file (hence the value objects constructors and method calls are still being intercepted)

                        Is there a limitation as to what can be dynamically intercepted?

                        Thanks,

                        Tim

                        • 9. Re: DynamicAOP not working with Examples
                          kabirkhan

                          I will try to look at your problem in the not too distant future

                          • 10. Re: DynamicAOP not working with Examples
                            kabirkhan

                            I could reproduce your problem, you can track progress here:

                            http://jira.jboss.com/jira/browse/JBAOP-217

                            • 11. Re: DynamicAOP not working with Examples
                              kabirkhan

                              The problem is to do with the bindings using $typedef{} not being picked up properly on redeploy.

                              I'll fix in cvs, in the meantime change

                               <typedef name="MyServlets" expr="class($instanceof{javax.servlet.http.HttpServlet}) AND class(org.jboss.injbossaop.web.*)"/>
                               <bind pointcut="execution(* $typedef{MyServlets}->service(..))">
                               <interceptor class="org.jboss.injbossaop.lib.SimpleInterceptor"/>
                               </bind>
                              
                               <typedef name="MySessionBeans" expr="class($instanceof{javax.ejb.SessionBean}) AND class(org.jboss.injbossaop.ejb.*)" />
                               <bind pointcut="execution(* $typedef{MySessionBeans}->getValue(..))">
                               <interceptor class="org.jboss.injbossaop.lib.SimpleInterceptor"/>
                               </bind>
                              
                              


                              to

                               <bind pointcut="execution(* org.jboss.injbossaop.web.EarExampleServlet->service(..))">
                               <interceptor class="org.jboss.injbossaop.lib.SimpleInterceptor"/>
                               </bind>
                              
                               <bind pointcut="execution(* org.jboss.injbossaop.ejb.ExampleSessionBean->getValue(..))">
                               <interceptor class="org.jboss.injbossaop.lib.SimpleInterceptor"/>
                               </bind>