Utilisation d'un bean de portée de requête en dehors d'une requête Web réelle

J'ai une application web qui a un Ressort de la logique d'Intégration en cours d'exécution avec elle dans un thread séparé. Le problème est qu'à un certain point de mon Ressort une logique d'Intégration essaie d'utiliser une portée de la requête bean et j'obtiens les erreurs suivantes:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.tenantContext': Scope 'request' 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 thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.


Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

J'ai le ContextLoaderListener ensemble:

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

Ma Portée Bean est annoté comme ça(depuis que j'ai entendu dire que proxing mon haricot aiderait):

@Component
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)  
public class TenantContext  implements Serializable {

Est ce que je fais possible?
Si oui, ce qui me manque ici?
Si non, d'autres suggestions sur comment je peux réaliser cela?

source d'informationauteur Diego Urenia