Question

I'm running a CDI based application on JBoss AS 7.1.1 which uses Conversation Scoped Beans. I need to invoke one of these beans from a RESTeasy Service. Unfortunately when I invoke the Conversation Scoped Bean

@Inject
private ConversationBean service; 


@GET
@Produces("text/html")
@Path("/book")
public void bookTicket(Long l) {

    service.book(l);
    . . . .
} 

the following error is returned:

Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped

Is there any workaround for this issue ?
Thanks!

Was it helpful?

Solution

I know I've answered this question before (or maybe it was @SessionScoped, same thing really). The Conversation is tied to a Session in CDI. As there are no Sessions in JAX-RS there are no conversations. In the spec section 6.7.4 it states that the Conversation scope is only active during JSF requests.

If you would like to create your own Scope and Context that acts like the conversation one and make it available to JAX-RS requests, that's certainly doable, but you'd have to have some location to store the scope and also associate it with a request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top