Announcement Announcement Module
No announcement yet.
Loggin AOP problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loggin AOP problem

    I have try to log with AOP but nothing seems to work it's like no logging want to appear i've tried from System.out.println to the INFO logger nothign!!!

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    <import resource="applicationContext.xml"/>
            <aop:aspect ref="LoggingAspect">
                <aop:pointcut id="myCutLogging"
                              expression="execution ( **.*(..) )"/>
                <aop:around pointcut-ref="myCutLogging" method="log"/>
        <bean id="LoggingAspect" class="org.ksique.aop.LogginAspect" />

  • #2
    Try to use your setup with the single config '*.xml' file (i.e. inline 'applicationContext.xml' content in place of '<import resource="applicationContext.xml"/>')


    • #3
      Try that but nothing

      I Tried that but still the same problem. BTW i logged directly on a method from a class in* and log pretty fine but i cannot get it done with AOP.

      Another small detail i am using IceFaces but i dont think that would matter to much right?


      • #4
        Originally posted by necronet View Post
        Another small detail i am using IceFaces but i dont think that would matter to much right?
        Not sure about that. General spring aop idea is to create aop proxy and provide it to the client instead of the target 'raw' bean. Every time proxy method is called it performs aop processing if necessary and delegates to the target 'raw' bean.

        That may be the case that IceFaces usage interferes with aop proxies construction and no proxy is created. Another possible case is that the proxies are created but they are not called, i.e. the call is performed on a 'raw' instance etc.

        I think that the best way to find the problem is to emulate it as a minimal but complete standalone example, post it here and ask for help on concrete example.


        • #5
          Thank you

          This is a little sample of what i want to do but i haven't being able to get it work

          i attached the src and web.


          • #6
            Sorry, but your example is incomplete - it doesn't contain information about libraries and versions that should be used with it.

            I tried it with tomcat 6.0.20 and the following key dependencies:
            HTML Code:
            However, I'm getting the following on Tomcat startup:
            Dec 14, 2009 4:18:19 PM org.apache.catalina.core.StandardContext listenerStart
            SEVERE: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
            java.lang.LinkageError: loader constraints violated when linking javax/el/ELResolver class
            	at org.apache.myfaces.webapp.Jsp21FacesInitializer.configureResolverForJSP(
            	at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(
            	at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(
            	at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(
            	at org.apache.catalina.core.StandardContext.listenerStart(
            	at org.apache.catalina.core.StandardContext.start(
            	at org.apache.catalina.core.ContainerBase.addChildInternal(
            	at org.apache.catalina.core.ContainerBase.addChild(
            	at org.apache.catalina.core.StandardHost.addChild(
            	at org.apache.catalina.startup.HostConfig.deployDescriptor(
            	at org.apache.catalina.startup.HostConfig.deployDescriptors(
            	at org.apache.catalina.startup.HostConfig.deployApps(
            	at org.apache.catalina.startup.HostConfig.start(
            	at org.apache.catalina.startup.HostConfig.lifecycleEvent(
            	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
            	at org.apache.catalina.core.ContainerBase.start(
            	at org.apache.catalina.core.StandardHost.start(
            	at org.apache.catalina.core.ContainerBase.start(
            	at org.apache.catalina.core.StandardEngine.start(
            	at org.apache.catalina.core.StandardService.start(
            	at org.apache.catalina.core.StandardServer.start(
            	at org.apache.catalina.startup.Catalina.start(
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
            	at java.lang.reflect.Method.invoke(
            	at org.apache.catalina.startup.Bootstrap.start(
            	at org.apache.catalina.startup.Bootstrap.main(
            I can check your example if it's really standalone (no servlet-container involved) or if you provide complete example configuration (maven pom.xml is fine for that).


            • #7
              Maven i tried but no success

              i am not that into maven i try to make the sample but i honestly did not get the whole maven idea!!!...... i'm stuck with my own i use:

              IceFace core
              IceFace support
              IceFace Facelest support


              • #8

                By the way i am using Glassfish V2


                • #9
                  Originally posted by necronet View Post
                  i am not that into maven i try to make the sample but i honestly did not get the whole maven idea!!!...... i'm stuck with my own i use:

                  IceFace core
                  IceFace support
                  IceFace Facelest support
                  I hope you realize that provided information doesn't allow to check your use-case at the local environment

                  I mean that I should try to setup the environment, try various versions of the libraries you mentioned to get your example working. It's not attractive enough to proceed


                  • #10
                    Thank you so much another try

                    i just create this .WAR with the source inside so you can run it easier. It's much simpler cuz i did not added the Facelet Libreries.

                    WAR link

                    PD. i really aprecciate your effort!!


                    • #11
                      I succeeded in running your example eventually.

                      1. Define target managed bean at the spring config (add the following declaration to it - '<bean id="testBean" class="com.test.BeanTest"/>');
                      2. Add 'cglib' library to your applications dependencies (necessary for creating aop proxy for the target bean);
                      3. Use 'SpringBeanVariableResolver' instead of 'DelegatingVariableResolver' at the 'faces-config.xml':
                        HTML Code:


                      • #12
                        Thank you it work

                        Well it work i just have one question why i couldnt do it with my bean on faces-config.xml isnt wrong to create two beans with the same name???

                        Spring context
                        <bean id="testBean" class="com.test.BeanTest"/>
                        Faces config
                        Or Spring has a way to keep both object with the same reference??
                        Last edited by necronet; Dec 16th, 2009, 01:56 AM. Reason: lack of code tags


                        • #13
                          Dude, I've never worked either with jsf or spring jsf at all

                          All I can do here is to provide you a guide line on how I sorted out your problem:
                          1. Started the application at your initial configuration;
                          2. Checked call stack when 'BeanTest.myMetodo()' was called and detected that spring was not involved to the processing;
                          3. Read javadoc for the spring class that was used at your config - DelegatingVariableResolver:
                            SF 1.1 VariableResolver that first delegates to the original resolver of the underlying JSF implementation (for resolving managed-bean objects as defined in faces-config.xml as well as well-known implicit EL attributes), then to the Spring root WebApplicationContext (for resolving Spring beans).
                          4. I know spring aop principles and realize that aop logic is involved only if aop proxy is called instead of the 'raw' bean, so, I became suspicious for the message 'first delegates to the original resolver of the underlying JSF implementation';
                          5. The javadoc also mentions JSF 1.1 VariableResolver, so, I checked what spring implementations of it are available over than DelegatingVariableResolver;
                          6. I found SpringBeanVariableResolver that states the following:
                            This is a subclass of the JSF 1.1 DelegatingVariableResolver, letting Spring bean definitions override other attributes of the same name.
                            So, it looked like it tries to use the beans from spring context whenever possible;
                          7. I checked DelegatingVariableResolver javadoc mentions jsf config snippet where jsf and spring stuffs are linked via spring bean name;
                          8. I tried to combine all of above together and checked that it works as expected now;

                          You can find all of the further jsf-related answers by yourself using the similar algorithm. Spring provides an excellent documentation (either reference or javadoc). Just don't be afraid to work with it.

                          One more important note - I believe that it's very-very-very-very-...-very important to avoid leaky abstractions, i.e. should have an understanding either of spring or jsf principles in order to be able to work with them at good level. I have a good spring knowledge and some basic understanding of JSF ideas, that helped me to find out the problem.


                          • #14
                            i apreciate it then thank you