9 Replies Latest reply on Dec 13, 2004 2:12 PM by Eduardo Leite

    Problem Compiling aspects

    Eduardo Leite Newbie

      Hi all,

      i am building some aspects to work with hibernate inside session beans.

      I created an aspect factory that instantiates a Hibernate SessionFactory and it's createPerVm methos instantiates a SessionFactory, binds it to an Aspect that holds the reference to the SessionFactory.

      The problem is that when I call the aopc task, it generates the following error:

      [aopc] org.jboss.aop.instrument.TransformationException: Failed to aspectiz
      e class br.com.quickmind.framework.persistence.HibernateAspectFactory. Could no
      t find class it references net.sf.hibernate.cfg.Configuration

      No method in this class is advisable considering my jboss-aop.xml.

      The compiler visits all the methods of this class, successfuly classifing them as not advisable.

      After the last method, the error message above is displayed.

      I am using Jboss-aop 1.0 final, the download available at the jboss site.


        • 1. Re: Deployer chains and interceptors
          Eduardo Leite Newbie

          yes at least this interceptor chain can use a typed interface, it does not makes sense to use the generic interceptor interface.

          one concern regarding to improve the WARDeployer would be to have tomcat use an input stream for web.xml when it deploys a war file instead of opening the stream by itslef.
          Thus that would avoid the rewrite the modified web.xml on the disk which overwrites the original document.

          • 2. Re: Problem Compiling aspects
            Eduardo Leite Newbie

            My last message was messed because of the XML stuff of my build file...
            Sorry for that.

             <path id="competence.compilation.classpath">
             <pathelement path="${hibernate.lib.dir}/hibernate2.jar"/>
             <pathelement path="${aop.lib.dir}/jboss-aop.jar"/>
             <pathelement path="${common.lib.dir}/log4j-1.2.9.jar"/>
             <pathelement path="${ejb.lib.dir}/jboss-j2ee.jar"/>
             <path id="aopctask.classpath">
             <fileset dir="${aop.lib.dir}"/>
             <path id="aopc.classpath">
             <path refid="aopctask.classpath"/>
             <path refid="competence.compilation.classpath"/>
             <aopc compilerclasspathref="aopc.classpath" verbose="true">
             <classpath path="${competence.classes.dir}"/>
             <src path="${competence.classes.dir}"/>
             <aoppath path="${aop.config}"/>

            • 3. Re: Problem Compiling aspects
              Bill Burke Master

              When you aopc your classes, make sure the hibernate libraries are in the classpath. This exception gets thrown because you are aspectizing a class that references the HibernateSessionFactory and the compiler cannot find this class to determine whether or not any other aspects/pointcuts are triggered.


              • 4. Re: Problem Compiling aspects
                Eduardo Leite Newbie

                I still does not understand what paths am I supposed to put on the task...

                And still does not work...

                The first two lines of the debug output:
                [aopc] [debug] jboss.aop.class.path is NULL
                [aopc] [debug] jboss.aop.search.classpath: 'null' true

                A new interesting point... if I take the reference to the Configuration object from Hibernate, everything works fine. Very strange...

                Any thoughts?

                • 5. Re: Problem Compiling aspects
                  Bill Burke Master

                  Add the Hiberante jars to your classpath element of the aopc target. I.e.:

                  <aopc ...
                   <classpath path="${competence.classes.dir}"/>
                   <classpath refid="aopc.classpath"/>
                   <src path="${competence.classes.dir}"/>
                   <aoppath path="${aop.config}"/>

                  Does that work?

                  • 6. Re: Problem Compiling aspects
                    Eduardo Leite Newbie

                    It does not work...

                    there is a weird thing happening here...

                    I took of the references to the configuration object in my code, and every thing works fine. Including code that uses classes of the Hibernate jar.

                    I use other concrete class for the package, and it worked too.

                    If I only declare a variable of type Configuration and puts null to it, it works. It only breaks when I use some method of this class.

                    Is there a way to tell aopc not to search this class to compile the aspects?

                    • 7. 3858523
                      Eduardo Leite Newbie

                      I analysed the hibernate jar and saw that the sf.net.hibernate.cfg.Configuration contains inner classes.

                      I tried to use a class of the log4j pack (the ConsoleAppender) and it worked nice. And it does not have inner classes.

                      Any clues?

                      • 8. Re: Problem Compiling aspects
                        Eduardo Leite Newbie

                        I reworked my code in such a way that the invocation for the Configuration class is out of the scope of the aopc compiler.

                        Now everything works fine.

                        Does anyone had any problems like this?

                        • 9. Re: Problem Compiling aspects
                          Bill Burke Master

                          It would help if you could send me an easy example that I can reproduce the problem. An example with Hibernate would be fine... bill@jboss.org

                          I'm sorry for your problems.