|
From: Robert R. <rob...@go...> - 2011-03-11 08:35:16
|
Hi all,
i'm using RESTEasy inside JBoss AS6 Final. When trying to inject and use a @ConversationScoped bean inside my JAX-RS resource class the following exception is thrown:
2011-03-09 08:07:08,687 ERROR Servlet.service() for servlet default threw exception: org.jboss.resteasy.spi.UnhandledException: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
...
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:643) [:6.0.0.Final]
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:77) [:6.0.0.Final]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:87) [:6.0.0.Final]
Is this a Bug or is the usage of ConversationScoped beans currently not supported? Is there a workaround to get an active transient ConversationContext inside my JAX-RS resource to prevent the exception? I'm not trying to establish a long running conversation using REST so a transient conversation would be sufficient. The @ConversationScoped is solely present/required because i'm reusing business logic that is also used via Web-UI.
Below is a small Testcase (derived from the resteasy-cdi-test module in the source distribution) demonstrating the scenario
Any help would be appreciated
Thanks, Robert
----------------------------------------
package org.jboss.resteasy.cdi.test.basic;
import javax.inject.Inject;
import javax.ws.rs.*;
import org.jboss.resteasy.cdi.test.ConverstationalCat;
@Path("/resource")
@Produces("text/plain")
public class TestResource {
@Inject
private ConverstationalCat cCat;
@GET
@Path("/fieldInjection")
public String fieldInjection()
{
return cCat.sayHello(); //throws org.jboss.weld.context.ContextNotActiveException
}
}
// -------------------------------------------------------------------------------------------------------------------
package org.jboss.resteasy.cdi.test;
import java.io.Serializable;
import javax.enterprise.context.ConversationScoped;
@ConversationScoped
public class ConverstationalCat implements Serializable
{
private static final long serialVersionUID = 5875753813720411262L;
public String sayHello() {
return "hello conversational cat";
}
}
|