Results 1 to 4 of 4

Thread: @Configurable usage during compile time weaving

  1. #1
    Join Date
    Jul 2006
    Location
    Prague
    Posts
    5

    Question @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. #2
    Join Date
    Nov 2007
    Posts
    420

    Default

    did you setup aop.xml?
    did you instrument your JVM?

  3. #3
    Join Date
    Jul 2006
    Location
    Prague
    Posts
    5

    Default

    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

  4. #4

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •