Announcement Announcement Module
Collapse
No announcement yet.
Error When using @Asynch support with named executor in 3.2.1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error When using @Asynch support with named executor in 3.2.1

    Test project: https://github.com/jasonparallel/asynchError (run junit and look for system out statements)

    When using the new value property of the asynch annotation execution will not occur.
    It appears that when AbstractAsyncExecutionAspect calls determineAsyncExecutor the beanFactory property of AsyncExecutionAspectSupport is null. Execution then stops at
    HTML Code:
    Assert.notNull(this.beanFactory,"BeanFactory must be set on " + this.getClass().getSimpleName() +" to access qualified executor [" + qualifier + "]");
    Is this a misconfiguration on my part or a bug in the implimentation?

  • #2
    This was caused by running the aspectj-maven-plugin and not setting the mode="aspectj"

    <task:annotation-driven mode="aspectj"/>

    Comment


    • #3
      Thanks for following up, Jason.

      Comment


      • #4
        I've had the same error using Java Configuration.

        Using AspectJ mode in the @EnableAsync annotation solves the problem.

        I have the aspectj-maven-plugin because it's a Roo project.

        NOTE: actually I need this class for a multithread test, so the best and fast option for me was a main class that uses Spring Configured with Java.

        Something like this:

        Code:
        @Configuration
        @EnableAsync(mode=AdviceMode.ASPECTJ)
        @ComponentScan(basePackageClasses={MainSpring.class})
        public class ExecutionConfiguration {
        	
        	@Bean
        	public ImageDownloader imageDownloader() {
        		return new ImageDownloaderHttpImpl();
        	}
        	
        	@Bean
        	public Executor imagesTaskExecutor() {
        		ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        		executor.setCorePoolSize(10);
        		executor.setMaxPoolSize(30);
        		executor.setThreadNamePrefix("ImagesTaskExecutor-");
        		return executor;
        	} 
        	
        }
        Code:
        @Component
        public class MainSpring {
        
        	@Autowired
        	private ImageDownloader imageDownloader;
        
        
        	public static void main(String... args) {
        		
        		logger.warn("READY");
        		
        		AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ExecutionConfiguration.class);
        		MainSpring mainSpring = ctx.getBean(MainSpring.class);
        
        		//...
        		mainSpring.downloadImages(...);
        
        	}
        
        	public List<ImagenDescargada> downloadImages(final String... strings) {
        
        		//...
        
        		List<Future<ImagenData>> futures = new ArrayList<Future<ImagenData>>();
        		for (String string : strings) {
        			futures.add(downloadImage(string));
        		}
        
        		//...
        	}
        
        	@Async("imagesTaskExecutor")
        	public Future<ImagenData> downloadImage(String string) {
        		//...
        		this.imageDownloader(...);//...
        		return new AsyncResult<ImagenData>(new ImagenData(...));
        	}

        Comment


        • #5
          Jut crashed my system..crippled now i guess..
          Last edited by Camillesmith; Jul 23rd, 2013, 03:26 AM.

          Comment

          Working...
          X