Announcement Announcement Module
Collapse
No announcement yet.
@Configurable usage during compile time weaving Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Configurable usage during compile time weaving

    Hello everyone,

    I am new to AspectJ with Spring and I am reading the chapter of http://static.springsource.org/sprin...-using-aspectj ---> 6.8.1. Using AspectJ to dependency inject domain objects with Spring

    So far as I understand, I need to enable in my application_Context.xml the use of this annotation. So in my application_context.xml I define

    <context:component-scan base-package="com.idc.cms" />
    <context:spring-configured />

    I have placed @Configurable in my class where I am accessing
    @Resource
    MyjdbcRepository myjdbcRepository;

    In MyjdbcRepository, I am using jdbcTemplate and access some of the sql queries.

    The problem: When I write my test, I try to access my @Configurable class and test the method which is using myjdbcRepository.getMyData(value); But I get NullPointerException.
    It seems that MyjdbcRepository class is not injecting properly. Can someone please explain / help me to find some solution for this?

    Thanks in advance,
    Regards,
    Meenakshi

  • #2
    did you setup aop.xml?
    did you instrument your JVM?

    Comment


    • #3
      Well, All I am trying to do is not to use Load time weaving. I want to use this in Compile time weaving.

      Also I am using Ant instead of Maven. So as far as I know, aop.xml is used for load time weaving.

      I came across something where I might need to create build.ajproperties file. Can someone help me out on this one?

      Thanks & Regards,
      Meenakshi

      Comment


      • #4
        You probably got your answer already, but for anyone else.

        A good way to setup compiletime weaving (in eclipse) is to use the ajdt plugin.
        Add the spring-aspects to the ajdt aspejtj build under the project properties.

        Now with the right settings in the spring xmls:

        <context:spring-configured/>

        the project should compile and be able to run in eclipsejee tomcat for instance.

        To compile it with ant:

        Code:
        
        		<taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
        	    	<classpath>
        	      		<pathelement location="${aspect.home}aspectjtools.jar"/>
        	    	</classpath>
        	  	</taskdef>
        
        
        
        		
        		<target name="compaspect">
        			<echo message=" **** Compiling aspect "/>
        			<mkdir dir="${build}/WEB-INF/classes"/>
        			<iajc 
        				 compliance="-1.5" 
        				srcdir="src"
        				destdir="${build}/WEB-INF/classes"
        				classpathref="compile.class.path" 
        				debug="true" 
        				deprecation="false" 
        				failonerror="true">
        				<aspectpath refid="aspect.path"/>    
        
        			</iajc>
        	    </target>
        
        
        		<path id="aspect.path">
        	        <pathelement path="${aspect.home}org.springframework.aspects-3.0.0.RELEASE.jar"/>
        	    </path>
        Its a bit of a struggle to set it up, but very nice when its all running.

        Comment

        Working...
        X