org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.syncDeque': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope

Spring JIRA | Sameer Bhatia | 8 months ago
  1. 0

    Configure a bean of type Collection with @JobScope for Spring Batch. {code:java} @Bean @JobScope public ConcurrentLinkedDeque<SyncMessage> syncDeque() { return new ConcurrentLinkedDeque<SyncMessage>(); } {code} This is where the exception is thrown in RabbitAdmin.java during RabbitMQ initialization. {code:java} initialize() { ... Collection<Collection> collections = this.applicationContext.getBeansOfType(Collection.class).values(); ... } {code} Stack Trace org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.syncDeque': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:355) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:534) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1162) at org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:395) at org.springframework.amqp.rabbit.core.RabbitAdmin$11.onCreate(RabbitAdmin.java:357) at org.springframework.amqp.rabbit.connection.CompositeConnectionListener.onCreate(CompositeConnectionListener.java:32) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:512) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:85) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:135) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:71) at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:456) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1171) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: No context holder available for job scope at org.springframework.batch.core.scope.JobScope.getContext(JobScope.java:159) at org.springframework.batch.core.scope.JobScope.get(JobScope.java:92) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340) ... 14 more

    Spring JIRA | 8 months ago | Sameer Bhatia
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.syncDeque': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope
  2. 0

    Configure a bean of type Collection with @JobScope for Spring Batch. {code:java} @Bean @JobScope public ConcurrentLinkedDeque<SyncMessage> syncDeque() { return new ConcurrentLinkedDeque<SyncMessage>(); } {code} This is where the exception is thrown in RabbitAdmin.java during RabbitMQ initialization. {code:java} initialize() { ... Collection<Collection> collections = this.applicationContext.getBeansOfType(Collection.class).values(); ... } {code} Stack Trace org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.syncDeque': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:355) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:534) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523) at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1162) at org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:395) at org.springframework.amqp.rabbit.core.RabbitAdmin$11.onCreate(RabbitAdmin.java:357) at org.springframework.amqp.rabbit.connection.CompositeConnectionListener.onCreate(CompositeConnectionListener.java:32) at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:512) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:85) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:135) at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:71) at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:456) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1171) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: No context holder available for job scope at org.springframework.batch.core.scope.JobScope.getContext(JobScope.java:159) at org.springframework.batch.core.scope.JobScope.get(JobScope.java:92) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340) ... 14 more

    Spring JIRA | 8 months ago | Sameer Bhatia
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.syncDeque': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope
  3. 0

    Spring batch : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.writer' when using JobScope

    Stack Overflow | 9 months ago | CKing
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.writer': Scope 'job' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for job scope
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Multi-threaded acces to Job Scope beans in Spring Batch 3.0

    Stack Overflow | 2 years ago | David Geary
    java.lang.IllegalStateException: No context holder available for job scope
  6. 0

    JdbcCursorItemReader test fails on step scope - Spring Forum

    spring.io | 1 year ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.assetItemReader': Scope 'step' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No context holder available for step scope

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      No context holder available for job scope

      at org.springframework.batch.core.scope.JobScope.getContext()
    2. Spring Batch Core
      JobScope.get
      1. org.springframework.batch.core.scope.JobScope.getContext(JobScope.java:159)
      2. org.springframework.batch.core.scope.JobScope.get(JobScope.java:92)
      2 frames
    3. Spring Beans
      DefaultListableBeanFactory.getBeansOfType
      1. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)
      2. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
      3. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:534)
      4. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523)
      4 frames
    4. Spring Context
      AbstractApplicationContext.getBeansOfType
      1. org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1162)
      1 frame
    5. Spring RabbitMQ Support
      SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run
      1. org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:395)
      2. org.springframework.amqp.rabbit.core.RabbitAdmin$11.onCreate(RabbitAdmin.java:357)
      3. org.springframework.amqp.rabbit.connection.CompositeConnectionListener.onCreate(CompositeConnectionListener.java:32)
      4. org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:512)
      5. org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:85)
      6. org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:135)
      7. org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:71)
      8. org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:456)
      9. org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1171)
      9 frames
    6. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame