[seam-dev] Seam REST and WELD-001303 No active contexts

Ove Ranheim oranheim at gmail.com
Mon Jan 16 17:35:20 EST 2012


Jason,

Thanks for your feedback and maybe this is a regression. I made an interceptor to make my test code work, but I'm not sure what implication it'll have in a production environment.

Ove

@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface ConversationAware {
}

@ConversationAware 
@Interceptor
public class ConversationHandler implements Serializable {

    private static final long serialVersionUID = -6414852756277060457L;
    
    private BoundConversationContext ctx;
    private BoundRequest request;
    
    private void createBoundConversationRequest() {
        request = new MutableBoundRequest(new HashMap<String, Object>(), new HashMap<String, Object>());
    }

    private void selectBoundConversationContext() {
        ctx = Container.instance().deploymentManager().instance().select(BoundConversationContext.class).get();
        ctx.associate(request);
        ctx.activate();
    }

    private void cleanupBoundConversation() {
        if (ctx != null && ctx.isActive()) {
            ctx.deactivate();
            ctx.dissociate(request);
        }
    }    

    @AroundInvoke
    public Object handle(InvocationContext ctx) throws Exception {
        if (ctx.getMethod().isAnnotationPresent( ConversationAware.class )) {
            createBoundConversationRequest();
            try {
                selectBoundConversationContext();
                return ctx.proceed();
            } finally {
                cleanupBoundConversation();
            }
        }
        return null;
    }    
}

@GET
@Path("/{id:[0-9][0-9]*}")
@Produces(MediaType.APPLICATION_JSON)
@ConversationAware
public Pojo lookupPojoById(@PathParam("id") Long id) {
    // do something
}    


On Jan 16, 2012, at 9:45 PM, Jason Porter wrote:

> I'd have to go through the seam conversation code as it is not documented. But I don't think the interceptor will work as in REST there isn't really a session to tie the conversation to. 
> 
> Sent from my iPhone
> 
> On Jan 16, 2012, at 13:35, Ove Ranheim <oranheim at gmail.com> wrote:
> 
>> I have configured class>org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor</class> in WEB-INF/beans.xml and seam-faces is used. In fact I use both JSF and REST.
>> 
>> Anything else that needs to be wired up?
>> 
>> On Jan 16, 2012, at 9:14 PM, Jason Porter wrote:
>> 
>>> If you're using Seam Conversation and starting the conversation it will work. Out of the box, conversations don't work outside JSF. 
>>> 
>>> Sent from my iPhone
>>> 
>>> On Jan 16, 2012, at 13:04, Ove Ranheim <oranheim at gmail.com> wrote:
>>> 
>>>> Hi guys,
>>>> 
>>>> I'm getting a "WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped" when making a call to a REST service that invokes a ConversationScoped bean.
>>>> 
>>>> Did I miss a configuration setting, or isn't ConversationScoped supported?
>>>> 
>>>> Ove
>>>> 
>>>> javax.ejb.EJBTransactionRolledbackException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
>>>>   org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:133)
>>>>   org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:196)
>>>>   org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:286)
>>>>   org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182)
>>>>   org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
>>>>   org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)
>>>>   org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
>>>>   org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
>>>>   org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
>>>>   org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
>>>>   org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
>>>>   org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
>>>>   com.parts.apartment.management.ApartmentService$$$view2.listApartmentUnits(Unknown Source)
>>>>   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>   java.lang.reflect.Method.invoke(Method.java:597)
>>>>   org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
>>>>   org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
>>>>   org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
>>>>   org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
>>>>   org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:125)
>>>>   org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62)
>>>>   org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
>>>>   com.parts.apartment.management.ApartmentService$Proxy$_$$_Weld$Proxy$.listApartmentUnits(ApartmentService$Proxy$_$$_Weld$Proxy$.java)
>>>>   com.parts.apartment.management.ApartmentService$Proxy$_$$_WeldClientProxy.listApartmentUnits(ApartmentService$Proxy$_$$_WeldClientProxy.java)
>>>>   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>   java.lang.reflect.Method.invoke(Method.java:597)
>>>>   org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
>>>>   org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255)
>>>>   org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
>>>>   org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
>>>>   org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)
>>>>   org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
>>>>   org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
>>>>   org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
>>>>   org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
>>>>   org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
>>>>   javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
>>>>   org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
>>>>   org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
>>>>   org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
>>>>   com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:126)
>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> seam-dev mailing list
>>>> seam-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/seam-dev
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20120116/334a4fdc/attachment-0001.html 


More information about the seam-dev mailing list